#!/usr/bin/perl -w ####################################################### # class2_03_defined # # trying out the defined() function, seeing that a variable # being undefined is NOT the same as it containing, say, an # empty string... # # modified by Sharon Tuttle from "Learning Perl", # by Schartz and Phoenix # # last modified: 4-10-03 ####################################################### $val1 = ""; # $val1 contains the empty string if (defined($val1)) { print "See? filling a \$val1 with the empty string IS defining it!\n"; } else { print "HUH? #1\n"; } # note that $val2 has NOT been defined yet... if (defined($val2)) { print "HUH?? #2\n"; } else { print "See? \$val2 is indeed undef\n"; } # end of class2_03_defined