Jun 22, 2008

Defining a undefined variable

If a variable is not defined, we can define like this instead of IF block.

#!F:\Perl\bin\perl
use strict;
use warnings;

# Very simple and easy to use
$a;
$a |= "prabhath";
print "\n Value is:", $a;


=cut
We can avoid the unnecessary if and defined code

$a = 'vamsi';
if ( not defined $a) {
$a = 'prabhath';
}
=cut

No comments:

Post a Comment