You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by martin langhoff <ma...@scim.net> on 2000/11/23 18:47:58 UTC

OT: packing and unpacking help!

hi,

	sorry to bother the list, but I'm stuck trying to convert this code
into something more elegant, using pack() ... 

my $commandlength = length $command;
my $high 	= (($commandlength & (255 << 8)) >> 8);
my $low		= ($commandlength & 255);
my $commandstr 	= sprintf("\002%c%c%c", $high, $low+1, scalar @arg -1) .
$command;

	the code is not mine, of course -- I don't know a drat about shifting
bits around--, its a rough conversion of some php code that we're using
in a module to administer qmail+vmailmgr via web-forms. the resulting
$command is going to be sent through a socket to a daemon that takes
care of administering the email server. 


	of course, if anyone is willing to tell me to RTFM and stop posting OT,
I'd be more than thankful if he/she includes a link to the FM (besides
perldoc, of course).




martin