Home: Perl Programming Help: Beginner:
Post deleted by cupofdoug


Mar 31, 2013, 6:47 PM

Views: 624
Post deleted by cupofdoug


Veteran / Moderator

Apr 1, 2013, 2:07 AM

Views: 612
Re: [cupofdoug] Perl newb seeking help with assignment

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:

my $ascii = ord $chunk;

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.