Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Script critique requested

by toolic (Bishop)
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.

Replies are listed 'Best First'.
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.)



Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://997271]
[erix]: true of life in general
LanX yeah if God had used GIT fromn the beginning ...
[LanX]: I'm working with legacy code which was ... ehm .. hacked long before I arrived here ...
[LanX]: ... try to explain to a "senior" that code which is "working" should be altered
[LanX]: hmm looks like the EU needs to prepare for a trade war with former allies ...
[erix]: lets boycott english
[LanX]: the language or the "Anglos" in general? ;-)

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2017-01-16 14:53 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (151 votes). Check out past polls.