Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: ActivePerl on Win32 storing integers as strings?

by LonelyPilgrim (Beadle)
on Feb 14, 2012 at 04:59 UTC ( [id://953612]=note: print w/replies, xml ) Need Help??


in reply to Re: ActivePerl on Win32 storing integers as strings?
in thread ActivePerl on Win32 storing integers as strings?

Thanks. I think so. So the issue is that unpack takes a string as an argument (which I now see on the description in perlfunc), so it's unpack itself that forces the number to be interpreted as a string? Packing it explicitly as an integer gives it an integer to unpack -- though pack, according to perlfunc, also produces a string. I guess I just lack a basic understanding about how Perl stores data. My understanding of data types is essentially C-centric (char or int or short or string).

Replies are listed 'Best First'.
Re^3: ActivePerl on Win32 storing integers as strings?
by BrowserUk (Patriarch) on Feb 14, 2012 at 05:17 UTC

    You're almost there.

    As you say, unpack takes a string as its argument. If you supply an integer, then Perl quietly converts it to a (human readable) string for you, just as it does when do print 0; It 'ascii-ises' the number. In C terms, Perl does an itoa() on it.

    Conversely, when you pack the number, the string returned contains the machine readable, binary representation embedded within a string. In C terms, it is like doing:

    int i = 0; printf( "%s", (char*)&i );

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?

      Thanks a lot; I think I've got it.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-24 03:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found