Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
Do you know where your variables are?
 
PerlMonks  

Re: Script critique requested

by toolic (Chancellor)
on Oct 04, 2012 at 17:32 UTC ( #997271=note: print w/ replies, xml ) Need Help??


in reply to Script critique requested

I think it can be simplified (subject to your <256 constraint) using printf:

use warnings; use strict; print "Enter a decimal number, less than 256, to be converted to a bin +ary number: "; chomp(my $dec = <STDIN>); printf "%08b\n", $dec;

See also the FAQ:

perldoc -q convert

But, yours is an interesting use of the <=> operator.


Comment on Re: Script critique requested
Select or Download Code
Re^2: Script critique requested
by jhumphreys (Novice) on Oct 04, 2012 at 17:39 UTC

    Toolic, thanks; and agreed, I just haven't learned the printf operator yet. (Slowly working my way through intro text by Cozens.)

    Best,

    J.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://997271]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (9)
As of 2014-04-17 00:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (437 votes), past polls