develooper Front page | perl.perl5.porters | Postings from September 2013

[perl #120047] perl should enable "$_" for use before calling subs

Thread Previous | Thread Next
Linda Walsh via RT
September 29, 2013 19:45
[perl #120047] perl should enable "$_" for use before calling subs
Message ID:
On Sun Sep 29 04:43:25 2013, LeonT wrote:
> On Sun Sep 29 02:26:28 2013, LAWalsh wrote:

> > Regardless of documentation that may justify this behavior, I would
> >    like to
> > see the design reasons for this behavior if such is to be found.
> > I see no logic in disabling $_, **randomly*** (based on callstack) in
> > a sub-function or library call but allowing it for built-ins. 
> When using $_ in a subroutine and you do not want it to affect or or be
> affected by the calling environment, you should use local on it. Or
> better yet, just use a lexical variable. Not doing so is a bug, your
> bug. Perl is behaving as intended and expected.

> Closing this as not-a-bug
As I said, referring to current behavior or saying that the current
buggy behavior is "by design", doesn't mean it isn't a bug.  That you
didn't understand that basic premise is typical of one who engages in
unthinking behavior in order to close bugs (not that you always do, but
*often* do).

If you can show what would be harmed by my change, I'll accept it as not
being a bug.  Otherwise, I assert you've placed a needless restriction
on library code -- that all of them must use "local" $_ --
which may be completely inappropriate, especially given that the
locality of $_ isn't preserved across lateral transfers of control made
with "goto".  

via perlbug:  queue: perl5 status: rejected

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About