On 8/4/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I am new in perl. i want print 2 valuable in same line but my script > it print split into 2 line. if i hard code will work. i dont > understand why is happen. can some please explain to me thanks, > > #!/usr/bin/perl > print "which client\n"; > $a = <>; > $db = <>; > $dir="/u1/data/$a"; > $avar="$dir/$db; > print "$avar";
$a and $db both end with a "\n" (LF on unix, CRLF on windows). This means that $avar has two "\n"s. This is why you are getting two lines. If you want to get only one line you need to use the chomp function to remove the "\n"s from the ends of your variables. Also, do not use the variable $a. It and $b are special variables. They are used by the sort function. #!/usr/bin/perl use strict; use warnings; my $adir = <>; chomp($adir); my $db = <>; chomp($db); my $dir = "/u1/data/$adir"; my $avar = "$dir/$db; print "$avar\n"; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
