Daniel Nascimento wrote:
Hello Andrew, thanks for your answer.

I tried to do this way:

*#!/usr/bin/perl -w

$res = qx/whoami/;

print $res;
print "-----------------\n";

if ($res eq "daniel"){
    print "Welcome, ".$res." how are you?.\n";
}else{
    print "Your name isn't daniel\n";
}*

when I executed this script I receive this output:

[EMAIL PROTECTED]:~/Desktop$ perl teste.pl
daniel
-----------------
Your name isn't daniel*


What I did wrong? The script output doesn't should be "Welcome, daniel how
are you?"??

At the line:

$res = qx/whoami/;

$res now contains the string "daniel\n" which is not equal to "daniel".

You need to chomp() any lines you get from qx//.

chomp( my $res = qx/whoami/ );

Or:

chomp( my @lines = qx/whoami/ );




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/


Reply via email to