Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: making a shorter code!

by tlhf (Scribe)
on Sep 15, 2002 at 00:51 UTC ( #197964=note: print w/replies, xml ) Need Help??


in reply to making a shorter code!

#!/usr/bin/perl -l print"Enter the distance to be converted:"; printf"$_ kilometers= %f miles\n$_ miles= %f kilometers",($_=<>)*0.621 +4,$_*1.609;

Is the shortest I could think of in a short period of time. At 144 bytes. The chomp seemed unecessary (Perl 5.6.1/Win32), and -l allowed me to skip \ns, and using printf allowed the three chars of %f and a commer, rather than "..". I didn't seem to get much benefit by using $m=miles or $m=' miles' tho.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2021-09-25 13:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?