On Mon, Jul 24, 2000 at 07:45:08PM -0400, Paul Schinder wrote: > At 4:14 PM -0700 7/24/00, Tom Sackett wrote: > >The same thing happens no matter how I rewrite line 3, I've tried the > >following: > > (my ($var) = "conga") unless (defined($var)); > > my ($var) = "conga" if (!defined($var)); > > (defined($var)) || (my ($var) = "conga"); > > > >Any idea what's going on, or what I can do about it? > > It *did* give you an warning message, didn't it? > > # "my" variable $var masks earlier declaration in same scope. > File 'Untitled'; Line 3 > The variable is: bongo > The variable is now: > > That's what's going on. You're "my"ing a variable twice in the same > scope, which is A Bad Thing. my has a compile time effect and a runtime effect, so in this code: my($var) = "conga" unless (defined($var)); the compile-time effect of lexicalizing $var occurs, *regardless* of the value of $var at runtime. This is an "undocumented feature". :) So, don't put a statement modifier on my() unless you know what you're doing. Ronald # ===== Want to unsubscribe from this list? # ===== Send mail with body "unsubscribe" to macperl-request@macperl.org