bl0rf has asked for the wisdom of the Perl Monks concerning the following question:
After reading the pack/unpack tutorial by pfaut I felt brave and decided to do some things with the scariest function in Perl. I saw something very weird that I hope you might explain to me.
The number above is the result of a concatenation of the letters ABCD ( I'll put the whole thing in the code snippets section later ). What I don't understand is why Perl convert the number into four characters instead of into a "long" number$number = 1145258561; print pack( "l", $number ); # prints: ABCD
I'm completely puzzled, and Perl even converts the number into the correct letters ( okay, I converted them to binary, concatenated and converted to a long again before doing the above ). Could somebody explain this madness to me, as my work with pack/unpack is purely hit-and-miss :-(
Thanks for your help.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: pack peculiarity
by !1 (Hermit) on Dec 26, 2003 at 21:50 UTC | |
Re: pack peculiarity
by revdiablo (Prior) on Dec 26, 2003 at 23:43 UTC | |
Re: pack peculiarity
by pg (Canon) on Dec 27, 2003 at 02:23 UTC | |
by sgifford (Prior) on Dec 27, 2003 at 06:58 UTC | |
by pg (Canon) on Dec 27, 2003 at 07:13 UTC | |
Re: pack peculiarity
by bl0rf (Pilgrim) on Dec 28, 2003 at 00:10 UTC |
Back to
Seekers of Perl Wisdom