in reply to Determine type of variable

You can think of Perl scalars as just being strings. Using any of these strings in a place that wants a numeric value will cause the string to (try to) be interpretted as a decimal numeral. There are some details beyond this that almost never matter.

pack creates a "raw" string of bytes from multiple input values. unpack creates multiple output values from a "raw" string of bytes.

The documentation for pack and unpack are terse enough that I usually have to resort to experimentation to flush out the details even though I am very familiar with them already. "perl -de 0" and its "x" command are very useful for this.

So most of the pack formats take a string holding the decimal representation of a number, and encode that number into the "raw" format mentioned in the description of that format character, returning the "packed" string that holds the bytes of that "raw-formatted" data concatenated together.

The exceptions are the formats that mention "string" in their description along with "x", "X", and "@".

So:

> perl -de 0 [...] DB<1> x pack("C","65") 0 'A' DB<2> x unpack("C*","\0\cA A") # yields ("0","1","32","65") 0 0 1 1 2 32 3 65 DB<3> x pack("n","1") 0 "\c@\cA"
where I've put quotes around many of the "numbers" even though they aren't required just to emphasize that Perl, to a great extent, simply treats them as strings that happen to contain valid decimal representations for numbers.

        - tye (but my friends call me "Tye")