Raymond Wan wrote:

On 5/8/09, John W. Krahn <jwkr...@shaw.ca> wrote:

[snip]

That is equivalent in C to:

unsigned char decimal_number = 42;

Or another way to write that in Perl is:

my $decimal_number = pack 'C', 42;


Once you have created the appropriate strings using pack() then just
print() them.


I see; thanks for the explanation.  I never used Perl for bits before,
so pack/unpack is still  new to me.  Until now, I just envisioned that
everything happens magically behind the scenes for me.  :-)

At this moment, I got it to work by not opening a file for binary
output.  Instead, I just print ()
to STDOUT.  It seems specifying whether the output file is binary or
now doesn't matter?  I thought it would...

That depends on the operating system you are using. I use Linux so there is no difference between "binary" and "text", except for those specific applications that can't handle "binary" data. If you are on a system like DOS/Windows then reading or writing "binary" data as "text" will cause problems because line ending translation occurs with "text" files but not with "binary" files.



John
--
Those people who think they know everything are a great
annoyance to those of us who do.        -- Isaac Asimov

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to