my $DEBUG if exists...

Nick Estes plug-devel@lists.PLUG.phoenix.az.us
Sat May 12 16:38:01 2001


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> my $gDEBUG = $DEBUG;
> my $fx = 'initialize';
> my $DEBUG = $fxDEBUG{$fx} and print "got <$fxDEBUG{$fx}>\n" if exists $fxDEBUG{$fx};
> print "Entering <$fx>. <$DEBUG> <$fxDEBUG{$fx}> <$gDEBUG>\n";
> 
> The 3rd line assigns a localized $DEBUG regardless of whether or not the
> $fxDEBUG{$fx} exists, is defined or just is, e.g. same story using defined
> or leaving out exists and defined.

Looks like an operator precedence problem, the binding for 'and' is very
very loose.  Try:

(my $DEBUG = $fxDEBUG{$fx} and print "for <$fxDEBUG{$fx}>\n") if exists $fxDEBUG{$fx};


> The variable assignment should place IFF the associated if statement
> evaluates as true, right?

With the low precendence of and, it would do the assignment, then only
print if it exists.

> If the value exists creation, assignment and the print statement take
> place as expected. If the value doesn't exist the localized variable is
> created with no value and the print statement doesn't go off.

exactly! 

	--Nick

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.2 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE6/z2Fv+hjYTGg7s4RAtIaAJ9j7hyrnlnc2U9rW448uu7CIq6BlwCfcqV6
irXXxN1cYvpdilhL4QsbgqI=
=5HTO
-----END PGP SIGNATURE-----