Table of Contents

False values versus Existence: It is, therefore...

Just because something is false doesn't mean to say it doesn't exist. A wig is false hair, but a wig exists. Your variable is still there. Perl does have a function to test if something exists. Existence, in Perl terms, means defined. So:

print "Car is defined !\n" if defined $car;
   

will evaluate to true, as the $car variable does in fact exist.

This begs the question of how to really wipe variables from the face of the earth, or at least your Perl script. Simple.

$car 	 ="Porsche 911";
$aircraft="G-BBNX";

&look;

undef $car; # this undefines $car

&look;

sub look {
	print "Car :$car: Aircraft:$aircraft:\n";
	print "Aircraft exists !\n"  if $aircraft;
	print "Car exists !\n" 	     if defined $car;
}
   

This variable $car is eradicated, deleted, killed, destroyed.

And now for something completely different....