in reply to Error Checking: Have you tried 'Try/Catch'?
I have a theory on this one. (Brace yourself...)
The only reason Perl can do that on the first argument is because it absolutely knows the first arg is a sub ref. If you had a prototype like foo($&), how is Perl to know what this means? (This is NOT a perfect example, but I think you can get the idea.)
foo $bar{$baz};
Is the {} a chunk of code, or someone trying to get a hash element and getting a scalar and a sub ref stored in that position? Obviously this depends on whether foo is a scalar or hash, but Larry and Friends decided not to write a complicated chunk of code for dealing with this, and I can't blame them. Just remember that the whole {}==sub{}, thing is a convenience only available when they can be absolutely sure of its meaning.
=cut
--Brent Dax
@HPAJ=split("", "rekcaH lreP rentonA tsuJ"); print reverse @HPAJ; #sucky but who cares?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Error Checking: Have you tried 'Try/Catch'?
by tadman (Prior) on Feb 20, 2001 at 15:02 UTC |