binary - View Perl Variables as Bytes/Bits -


disclaimer: it's been ages since i've done perl, if i'm asking/saying stupid please correct me.

is possible view byte/bit representation of perl variable? is, if like

my $foo = 'a'; 

i know (think?) computer sees $foo

0b1100010 

is there way perl print out binary representation of variable?

(not asking practical purpose, tinkering around old friend , trying understand more did in 1997)

sure, using unpack:

print unpack "b*", $foo; 

example:

% perl -e 'print unpack "b*", "bar";' 011000100110000101110010 

the perldoc pages pack , perlpacktut give nice overview converting between different representations.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -