I could, but the book also mentions a hint to using the bitwise operator.
Loops are still to come. =)

Ryan

From:  Hal Wigoda <hal.wig...@gmail.com>
Date:  Mon, 12 Sep 2011 14:07:18 -0500
To:  Ryan Munson <ryan.barrac...@elboardo.com>
Subject:  Re: need some help with writing a basic program


Use a while or for loop

On Sep 12, 2011 1:58 PM, "Ryan Munson" <ryan.barrac...@elboardo.com> wrote:
> Hi all,
> 
> I am running through a good book on Perl and am having some issues with a
> script I am trying to create for one of the practice exercises (I am
> teaching myself Perl for work). Just to let you know the solution does not
> involve using an if statement because this is in the next chapter.
> 
> The objective is to "Write a program that asks for a decimal less than 256
> and converts it to binary."
> 
> Any help would be greatly appreciated!
> 
> #!/usr/bin/perl
> # dec-less-than-exercise.pl <http://dec-less-than-exercise.pl>
> 
> use strict;
> use warnings;
> 
> print "Decimal Less Than 1.0\n\nPlease enter a decimal number less than 256:
> ";
> 
> chomp(my $dec = <STDIN>);
> $dec = $dec < 256;
> print $dec, "is less than 256! ", "\n";
> $dec = oct($dec);
> print $dec, "is your binary value. ", "\n";
> 
> Ryan Munson
> 
> 
> 


Reply via email to