RE: output in a single line




you forgot to chomp both your currency holders. Both contain a newline at
the end, but the second one _appears_ ok to your eyes coz its the end of the
line. You should chomp both (as shown below), and then format your output
with any newlines if necessary...

|-----Original Message-----
|From: Vineet Pande [mailto:pande_vineet@xxxxxxxxxxx]
|Sent: Wednesday, May 25, 2005 2:30 PM
|To: beginners@xxxxxxxx
|Subject: output in a single line
|
|
|Hi
|I tried the following script
|
#!/usr/bin/perl
use warnings;
use strict;
print "Currency converter\n\nPlease enter the exchange rate: ";
our $rupee_c1 = <STDIN>;
chomp($rupee_c1) ;
print "Please enter the Amount in Rupees: ";
our $rupee = <STDIN>;
chomp($rupee) ;
print "$rupee rupees are ", ($rupee/$rupee_c1), " Euros\n";

when i execute this, i get
|
|Currency converter
|
|Please enter the exchange rate: 56
|Please enter the Amount in Rupees: 560
|560
|rupees are 10 Euros
|I AM NOT ABLE TO UNDERSTAND WHY 560 IS FOLLOWED BY RUPEES ARE 10 EUROS IN
|THE NEXT LINE. IS IT THE FAULT OF print "$rupee..........BECAUSE
|WHEN I SAY
|PRINT "560 ...., INSTEAD OF VARIABLE NAME, I GET THE OUTPUT IN A SINGLE
|LINE.
|
|
|Any help appreciated
|cheers
|vineet
|
|"The future belongs to those who believe in the beauty of their dreams"
|-Eleanor Roosevelt
|
|_________________________________________________________________
|Express yourself instantly with MSN Messenger! Download today it's FREE!
|http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
|
|
|--
|To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
|For additional commands, e-mail: beginners-help@xxxxxxxx
|<http://learn.perl.org/> <http://learn.perl.org/first-response>
|
|


*********************************************************
Disclaimer:

The contents of this E-mail (including the contents of the enclosure(s) or attachment(s) if any) are privileged and confidential material of MBT and should not be disclosed to, used by or copied in any manner by anyone other than the intended addressee(s). In case you are not the desired addressee, you should delete this message and/or re-direct it to the sender. The views expressed in this E-mail message (including the enclosure(s) or attachment(s) if any) are those of the individual sender, except where the sender expressly, and with authority, states them to be the views of MBT.

This e-mail message including attachment/(s), if any, is believed to be free of any virus. However, it is the responsibility of the recipient to ensure that it is virus free and MBT is not responsible for any loss or damage arising in any way from its use

*********************************************************
.



Relevant Pages

  • Re: File::Slurp and using it with chomp
    ... > will be using it in the future in scripts where many files get read, ... > qw(slurp) makes sure slurpis an alias for read_fileto shorten it ... chomp does not returne the chomp'ed string. ... Your code looks as though you're attempting to remove the newline from ...
    (comp.lang.perl.misc)
  • Re: Please help me with parsing
    ... chomp removes a newline from its argument. ... Again with `perldoc -q quoting`, but more importantly, your original ...
    (perl.beginners)
  • Re: Newbie question on split, and also awk.
    ... I'm pulling data lists from the OS, ... One way to test whether something is a newline or not ... chomp $nislist; ... group member list (perhaps as a hash, ...
    (comp.lang.perl.misc)
  • Re: File::Slurp and using it with chomp
    ... >> will be using it in the future in scripts where many files get read, ... >> qw(slurp) makes sure slurpis an alias for read_fileto shorten it ... >> single line files contain a newline at the end. ... > chomp does not returne the chomp'ed string. ...
    (comp.lang.perl.misc)