On Oct 25, 9:21 am, simssa...@gmail.com (saran) wrote:
> i am new to perl. please help me with this piece of code below.
> answer wat it prints is correct but the format has to adjusted...!
> program to convert Celsius to Fahrenheit
> **********************************************************************************
> #!/usr/bin/perl
> use warnings;
> use strict;
>
> print "Celsius to Fahrenheit Conversion\n";
> print "Enter the value of Celsius to be converted:";
>
> my $c = <STDIN>;
> my $f = ($c*1.8) + 32;
> print "$c"."C is equal to ", "$f","F","\n"
>
> ***************************************************************************
> Output
>
> Celsius to Fahrenheit Conversion
> Enter the value of Celsius to be converted:40
> 40
> C is equal to 104F
> *************************************************************************
>
> why does "C is equal to 104F" prints on a new line rather than "40 C
> is equal to 104F"
> on a single line...
> please help

See:  perldoc -f chomp

my $c = <STDIN>;  # or chomp( my $c = <STDIN>)
chomp $c;
...


--
Charles DeRykus


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to