JayBonci has asked for the wisdom of the Perl Monks concerning the following question:
Assuming you had some kind of code that you were checking for existance before formatting on one line, you get this:my $foo= (my $bar = localtime)?("$bar hello"):("FAILED!");
Why doesn't $bar propagate down to it's child conditions? This is bewildering because this works as expected:Global symbol "$bar" requires explicit package name at ./scope.pl line + (whatever)
I realize that the above construct probably isn't the internal representation of the ternary operator, but it is the logical expansion. If anyone has any additional info on what the perl internal structure on this is, I'd be happy to find out. Thanksprint do { if(my $bar = localtime){ "$bar hello"}else{ "FAILED!" } };
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Variable scope in ternary ?: operator not propagating?
by Abigail-II (Bishop) on Mar 11, 2003 at 21:03 UTC | |
Re: Variable scope in ternary ?: operator not propagating?
by Zaxo (Archbishop) on Mar 11, 2003 at 21:03 UTC | |
Re: Variable scope in ternary ?: operator not propagating?
by TimToady (Parson) on Mar 12, 2003 at 16:18 UTC | |
by theorbtwo (Prior) on Mar 15, 2003 at 04:28 UTC | |
by Aristotle (Chancellor) on Mar 16, 2003 at 00:04 UTC | |
Re: Variable scope in ternary ?: operator not propagating? (do)
by tye (Sage) on Mar 11, 2003 at 23:40 UTC | |
Re: Variable scope in ternary ?: operator not propagating?
by clairudjinn (Beadle) on Mar 11, 2003 at 23:00 UTC |