I wouldn't run off to p5p just yet...but that's me, you may get better and/or quicker answers there from someone who has a 64-bit system to play with. That said, of you go there, do so via the perl5porters@perl.com list rather than perlbug as what my snippet did prove is that this isn't a perlbug. Your just using it wrong:)

One thing I notice is that you are attempting to pack a 16-bit numeric value by splitting it into two 8-bit values and using 'CC' and switching the bytes around to account for the endianess of the current system.

A) I think that you are doing this wrongly.

B) There is no need for you to do this sort of thing yourself. pack already has that smarts built-in, although it requires you to pass along some clue bats to enable it.

pack has format specifiers 'n' and 'v' which will pack a 16-bit unsigned value from a number in a perl scalar, in either big-endian or little-endian format respectively.

Also, you don't show where or how your $BIG_ENDIAN variable is being set, but you should take a look at the Config package which is a part of the standard distribution. In particular

use Config; print $Config{ byteorder };

will tell you the order of the bytes on the current system. It will probably return somethng like '12345678' or '78563412' on your system.

Hope this helps.

Update: You might also want to check out perlpacktut. It's about the best tutorial i've seen on pack. You may have a local copy, but it is fairly recent addition to the doc set,so the link above may help.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
If I understand your problem, I can solve it! Of course, the same can be said for you.


In reply to Re: Re: Re: Re: Re: 64 bit pointer to string by BrowserUk
in thread 64 bit pointer to string by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.