in reply to Re^2: Mr. Ternary is greater than Mrs. If Else
in thread Mr. Ternary is greater than Mrs. If Else
yes, readability at first is a problem with Mr. Ternary... i can't get wrong with that... but as often you use the ternary operator becomes handy. but wait my delima was this "\&". what was that execption for in the strict pragma?
I think it is your dilemma, and yes: I had never seen it. Indeed, had you asked me, I would have guessed it was no valid syntax at all. And while I'm far from being a guru myself, I've seen quite a lot of code over the years, from gurus too. However reasoning on it a little, it's easy to see it simply amounts to taking a real reference after taking a symbolic dereference. The exception perldoc strict talks about is that that particular symbolic dereference, in that situation, doesn't issue an error, while it would in all the other situations:
C:\temp>perl -wMstrict -e "\&{'foo'}" Useless use of reference constructor in void context at -e line 1. C:\temp>perl -wMstrict -e "&{'foo'}" Can't use string ("foo") as a subroutine ref while "strict refs" in us +e at -e line 1.
Why you think you can use that instead of eval is completely out of my comprehension. The semantics is completely different.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Mr. Ternary is greater than Mrs. If Else
by shmem (Chancellor) on May 19, 2007 at 19:12 UTC | |
by blazar (Canon) on May 20, 2007 at 12:13 UTC | |
|
Re^4: Mr. Ternary is greater than Mrs. If Else
by PerlPhi (Sexton) on May 19, 2007 at 18:46 UTC | |
by shmem (Chancellor) on May 19, 2007 at 19:23 UTC | |
by PerlPhi (Sexton) on May 19, 2007 at 19:40 UTC | |
by blazar (Canon) on May 20, 2007 at 12:26 UTC |