when I run the following script.pl script with no arguments:
./script.pl
I do not get the message No arg. Why? How to identify if $param is a null value or empty value, same as [ -z from ksh?
#!/usr/bin/perl
my $param = $ARGV[0];
if ($param = "") {
print No arg;
} else {
print arg: $param;
}
Because it’s not Perl. Where did you learn that syntax? So much is wrong with it.
$param = ""assigns an empty string to$param, that’s not what you want.null is spelled
undefin Perl.To compare strings, use the
eqoperator.You must quote strings:
print "No arg"Much easier: