Perl - Checking if a variable is null
code:
#!/usr/local/bin/perl -w
$string = "ali,veli,gel";
my($a1,$a2,$a3,$a4) = split(',',$string);
if($a1) {print "$a1 ne guzel\n";}
else {print "Sicar\n";}
if($a2) {print "$a2 ne guzel\n";}
else {print "Sicar\n";}
if($a3) {print "$a3 ne guzel\n";}
else {print "Sicar\n";}
if($a4) {print "$a4 ne guzel\n";}
else {print "Sicar\n";}
output:
ali ne guzel
veli ne guzel
gel ne guzel
Sicar
0 Comments:
Post a Comment
<< Home