G
Guest
Hi everyone,
I have spent a few hours looking on Google, Perl.com, CPAN etc to try find
some information on messing about with low leveldata in Perl. I am talking
about opening files and looking at them in their very simplest format, 1s
and 0s.
What I have noticed from my searches so far is things like pack(), unpack(),
binmode() and some other stuff, but not really what I'm looking for, AFAIK.
Actually, you're in the right direction. pack(), unpack(), ord(), chr(), vec()
and sometimes sprintf() (sprintf mostly for the "looking at" part)
I look at them kind of like a letter "1" and then there is a binary
1, (031x and ^A I believe). Unless you tell it with unpack() (or for single
byte ASCII ord()) that you're really interested in it numerically, perl will treat
the data as text.
$a = 'A';
$a + 1; # is '1'
ord($a) + 1 # Should now be 66.
Sometimes I'll add a zero to something to force numeric context:
$a += 0;
Jamie