Perl: if with undefined variable

Self-tutoring about comp-sci: the tutor mentions Perl’s reaction to if(var), var undefined.

In yesterday’s post I mention about LISP and its reaction to a few “if” situations. In particular, LISP won’t tolerate being asked “if” about an undefined variable.

LISP, to be sure, allows a “no-holds-barred” programming style. So does Perl, but Perl seems less delicate. For instance, if($var) is “false” in Perl when $var=0 or even if $var has never been declared. Otherwise it’s true. Such is my experience, anyway.

Jack of Oracle Tutoring by Jack and Diane, Campbell River, BC.

Leave a Reply