in reply to Using ternary operator as lvalue in push
Having read this thread, I think I would describe this as a case of The Price We Pay For Perl's Magic. The only other place I think of where I've seen something similar, is on a magic print-to-filehandle.
Compare
my $scalar; print $scalar "sausage";
and
my %hash = ( x => 'XYZ' ); print $hash{x} "sausage";
The first compiles but the second generates a String found where operator expected compile time error (print tells you how to get round this problem, if you're interested).
I think this is a limitation in feature of Perl, and we're just going to have to live with it.
update: oha makes a fair point, and one that I agree with. It was a poor choice of words on my part. Post updated
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Using ternary operator as lvalue in push
by TimToady (Parson) on Aug 01, 2007 at 17:17 UTC | |
by dada (Chaplain) on Aug 02, 2007 at 14:51 UTC | |
by polettix (Vicar) on Aug 02, 2007 at 14:57 UTC | |
|
Re^2: Using ternary operator as lvalue in push
by oha (Friar) on Aug 01, 2007 at 09:43 UTC | |
by jhourcle (Prior) on Aug 01, 2007 at 16:31 UTC |