Apr 1, 2013, 2:07 AM
Post #2 of 2
Looking at the code you supplied in the attachment, you already know how to read one character at a time from the file. The instruction provided tell you to use the ord function to convert a character into its ASCII value. If your character is in the $chunk variable (as in your existing code), you just have to do something like this:
Re: [cupofdoug] Perl newb seeking help with assignment
[In reply to]
Similarly, your instructions tell you to use the sprintf function to convert the ASCII value into binary format. Just apply the recipe provided to you:
my $binary = sprintf ("%08b", $ascii);
Then you just have to print $binary to your output file.
I really do not see what is complicated for you in this assignment, which tells you how to do the things that are required.