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



cupofdoug
Novice

Mar 31, 2013, 6:47 PM


Views: 605
Post deleted by cupofdoug

 


Laurent_R
Veteran / Moderator

Apr 1, 2013, 2:07 AM


Views: 593
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:


Code
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:


Code
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.