P is for Practical | |
PerlMonks |
Re: Re: source filters in evalby ihb (Deacon) |
on Feb 25, 2003 at 10:56 UTC ( [id://238404]=note: print w/replies, xml ) | Need Help?? |
But using '::' to indicate the version found in the current package ...
The :: doesn't indicate the subroutine is found in the current package. On the contrary. It clearly (?) specifies which package the subroutine is found in, and that's main. ... is preferable to '&' so that you avoid '@_' being passed unmodified from the calling context to the scope of the subroutineUsing & doesn't necessarily mean @_ gets passed. That only happens if there is no parenthesis. If you look at the OP, you'll see that it asks about &eval(). And looking at the prototype of &eval makes it clear that it always is supposed to be called with one argument, so the behaviour you speak of is quite unlikely to happen. So, using :: is not preferable to &. The only advantage is that it still honours prototypes, but the downside is that you package qualify the subroutine so when you move it you'll have to rename all calls to it. The real fix, as you say, is to not name it "eval". ihb
In Section
Seekers of Perl Wisdom
|
|