-----Original Message-----
>From: jinto12 <[EMAIL PROTECTED]>
>Sent: Aug 22, 2007 3:24 PM
>To: beginners@perl.org
>Subject: I need and explanation for this.
>
>Ok im just starting to learn perl. what im basically doing is asking
>the user for a couple of inputs and then appending in it to a file.
>but when write them to a file, it writes each input in one line and
>the next input in the next line, so isnt it supposed to added in a
>single line? and how can i add them as a single line? i need help to
>get out of this confusion.
>
>something like this
>
>open DF, ">> datafile.txt" ;
>
>print "enter name "
>$a=<STDIN>;
>print  "enter age";
>$b=<STDIN>;
>
>$c="$a + $b"
>print DF $c;
>

1) you need a chomp to strip the newline symbol,so it should be,

$x=<STDIN>;chomp $x;
$y=<STDIN>;chomp $y;

please don't use $a,$b as variable names.

2) Perl use '.' for strings connection,not '+'.So you need,

$c = $x . ' ' . $y;

3) You may need to always add 'use strict' and 'use warnings' at the begin of 
scripts,like,

#!/usr/bin/perl
use strict;
use warnings;
...


--
Jeff Pang - [EMAIL PROTECTED]
http://home.arcor.de/jeffpang/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to