Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Re: Re: Re: $_ haters anonymou

by tilly (Archbishop)
on Dec 11, 2000 at 16:04 UTC ( [id://46066]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: $_ haters anonymou
in thread $_ haters anonymou

Well why not have $_ be automatically lexical?

Works perfectly well. But breaks backwards compatibility. But I think it will happen in Perl 6.

Replies are listed 'Best First'.
(lexical $_) Re: $_ haters anonymou
by dchetlin (Friar) on Dec 11, 2000 at 16:17 UTC
    Enh, but then it's impossible to define subroutines that work like built-ins such as chomp.

    I do that not infrequently.

    However, I wouldn't mind having to go through hoops to get there. Perhaps a subroutine attribute would have to be set to allow you access to $_.

    sub mychomp : getunderscore { s[${/}\z][]; }

    That way, no one could clobber $_ without intending to. And we could also add a pragma to disallow code outside of your file (or perhaps package) from clobbering $_ even if it wanted to.

    -dlc

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://46066]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (7)
As of 2024-04-23 17:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found