A
Amaninder
Hi everyone
I am new to perl and i am using ActiveState and activePerl 5.6 Can
someone help in figuring out why the variable $error has value of 1 in
it.
Here is the code.
#!/usr/bin/perl -w
use strict;
sub getExpectedResultFromFile{
my $fileName = shift;
my $index = shift;
my ($errorMess, @resultAtIndex, $line);
#if the parameter are wrong then quit with an error
unless ( defined($fileName) && defined($index) &&
$fileName =~ /.+/ && $index =~ /.+/ ){
$errorMess = "getExpectedResultFromFile(): Either \$fileName or
\$index is not correct";
return($errorMess, @resultAtIndex);
}
#open the file
}
my ($error , @result) = getExpectedResultFromFile("file.txt", "abc");
print "\n\$error===='$error'";
print "\n\@result===='@result'";
Here is the result
$error===='1'
@result====''
I dont understand why $error = 1. I never assigned 1 to $error in my
code. If someone knows the reason please let me know.
Thanks in advance
Amaninder
I am new to perl and i am using ActiveState and activePerl 5.6 Can
someone help in figuring out why the variable $error has value of 1 in
it.
Here is the code.
#!/usr/bin/perl -w
use strict;
sub getExpectedResultFromFile{
my $fileName = shift;
my $index = shift;
my ($errorMess, @resultAtIndex, $line);
#if the parameter are wrong then quit with an error
unless ( defined($fileName) && defined($index) &&
$fileName =~ /.+/ && $index =~ /.+/ ){
$errorMess = "getExpectedResultFromFile(): Either \$fileName or
\$index is not correct";
return($errorMess, @resultAtIndex);
}
#open the file
}
my ($error , @result) = getExpectedResultFromFile("file.txt", "abc");
print "\n\$error===='$error'";
print "\n\@result===='@result'";
Here is the result
$error===='1'
@result====''
I dont understand why $error = 1. I never assigned 1 to $error in my
code. If someone knows the reason please let me know.
Thanks in advance
Amaninder