in reply to making a shorter code!

I don't see any. I don't see any reason for compressing it like that though - life is not a JAPH contest. Getting rid of temporary variables where sensible is good - getting rid of legibility is not. And while it may just seem like nitpickery here, make sure to get in the habit of strict and warnings. I'd write this as follows:
#!/usr/bin/perl -w use strict; print "Enter the distance to be converted:\n"; chomp($_=<>); print "$_ kilometers= ", $_*0.6214, "miles\n", "$_ miles= ", $_*1.609, " kilometers\n";
For this example you could take advantage of the -l switch to Perl (see perldoc perlrun) to get rid of some line noise (pay attention to the shebang line):
#!/usr/bin/perl -wl use strict; print "Enter the distance to be converted:"; $_=<>; print "$_ kilometers= ", $_*0.6214, "miles"; print "$_ miles= ", $_*1.609, " kilometers";

Makeshifts last the longest.

Replies are listed 'Best First'.
Re: Re: making a shorter code!
by mowgli (Friar) on Sep 15, 2002 at 02:12 UTC
    And while it may just seem like nitpickery here, make sure to get in the habit of strict and warnings. I'd write this as follows
    At the risk of being nit-picky as well, I think it should be emphasized that things like using strict and enabling warnings etc., while generally helpful, are not forced upon the user in perl for a reason - so why should we try to enforce them on a cultural level when we don't do it on the technical one? It's all about choice.

      Well, I don't use strict for my oneliners. :-) As with many other things, you should stick to accepted good practice unless you understand why it is accepted good practice. (And even then you'll find yourself sticking to it most of the time.)

      Perl6 will be stricter than Perl5 by default for sensible cases, which I'm looking forward to.

      Makeshifts last the longest.