not null cheking of an argument in perl

Hi,

I have to check whether an argument say $ARGV[1] is not null in an if operator. Please let me know the operator. It would be great if you write a psuedo code.

Thanks in advance
Ammu

A couple of ways to do this.

VAR=
if [ -z "${VAR}" ] ; then
  echo "VAR contains nothing"
fi

or

VAR=
if [ x"${VAR}" = x ] ; then
  echo "VAR contains nothing"
fi

edit: My bad. I did not notice that you asked for it in perl

Hi Vino,

Thanks for replying. I just want to know whether -z will work in perl script.

if it works then the code should be something like

if ( -z "$ARGV[2]" ) then.....fi

Please correct me if I am wrong

Thanks
Ammu

if ($ARGV[1] eq "") { print "Empty\n";}

Jean-Pierre.

for not null checking in perl,

how about using

if ( ! defined $var  ) {
  print "not defined\n";
}
else {
  print "defined\n";
}