[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";
When you use something like:
$a = <>;
you are getting the contents of $a from the command line and it will include a
newline at the end so when you see:
which client
and you type:
cold1man
your perl program assigns the string "cold1man\n" to the variable $a. You
need to chomp the variables first before you can use them:
#!/usr/bin/perl
use warnings;
use strict;
print "which client\n";
my $a = <>;
chomp $a;
my $db = <>;
chomp $db;
my $dir="/u1/data/$a";
my $avar="$dir/$db;
print "$avar";
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/