Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Is the documentation for Perl 5.20 'pack' correct?

by Corion (Patriarch)
on Jul 06, 2015 at 20:27 UTC ( [id://1133437]=note: print w/replies, xml ) Need Help??


in reply to Is the documentation for Perl 5.20 'pack' correct?

Endianness even has examples that try to illustrate the issue. Depending on how you display "increasing address space", the values/ordering may appear the other way around.

On the subject itself, you'll have to tell us what the byte order on disk was :-)

Replies are listed 'Best First'.
Re^2: Is the documentation for Perl 5.20 'pack' correct? (l2r)
by tye (Sage) on Jul 06, 2015 at 21:19 UTC
    Depending on how you display "increasing address space", the values/ordering may appear the other way around.

    The OP was using strings and Perl strings (displayed in English) increase addresses to the right.

    So, yes, the quoted documentation disagrees with wikipedia.

    - tye        

      Wikipedia neither agrees nor disagrees with the OP's quote, since the part he quoted makes no sense out of context. 12345678 has no inherent endianness.

      Wikipedia neither agrees nor disagrees with the docs, as it is silent on the value output by perl -V:byteorder.

      'So, yes, the quoted documentation disagrees with wikipedia.'

      And what does that mean?
Re^2: Is the documentation for Perl 5.20 'pack' correct?
by flexvault (Monsignor) on Jul 06, 2015 at 23:52 UTC

    Hello Corion,

      ...you'll have to tell us what the byte order on disk was :-)

    Displaying the disk file in hex, the packed number 16909060 is:

    my $packed_number = pack( "N", 16909060 );
    displayed as hex '01020304' :-)

    Further, you can just do the following:

    my $packed_number = pack( "N", 16909060 ); print unpack("H8",$packed_number),"\n";
    which yields hex '01020304'.

    Regards...Ed

    "Well done is better than well said." - Benjamin Franklin

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1133437]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-03-28 13:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found