How many ways to verify Perl scalar variable is initialized or defined?
Method1:
if !(defined $a)
{
}
Method2:
$a = defined $a? $a : { };
Method3:
$a = "Hi" unless defined $a;
Method4:
$a = $a || "Hi";
Method5:
$a ||= "Hi";
Method6:
if ( length( $a || '' ))
{
}
kaavannan perl blogspot
Labels: if defined in perl, kaavannan perl blogspot, perl check if variable is defined, perl check if variable is empty, perl check if variable is undefined, perl if defined and not empty, perl variables
0 Comments:
Post a Comment
Note: only a member of this blog may post a comment.
<< Home