Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: (nearly) readonly globals

by BrowserUk (Pope)
on Jan 19, 2009 at 20:18 UTC ( #737394=note: print w/replies, xml ) Need Help??


in reply to (nearly) readonly globals

Is there a bug? Are the docs ambiguous?

No. And No. Using local creates a temporary instance of the named variable, and you can do what you like with it.

That WAD (Working As Designed)


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: (nearly) readonly globals
by haoess (Curate) on Jan 19, 2009 at 20:32 UTC
    Using local creates a temporary instance of the named variable, and you can do what you like with it.

    But this does not apply to all special globals, i.e.:

    % perl -e 'local $1 = 1' Modification of a read-only value attempted at -e line 1. % perl -e 'local $^S = 1' Modification of a read-only value attempted at -e line 1.

    -- Frank

        I don't give up:

        % bleadperl -Mstrict -wE 'for $1 ( 10..13 ) { say $1 }' 10 11 12 13

        And now, these globals loose their magic:

        % bleadperl -Mstrict -wE 'for $1 ( 10..13 ) { $1 =~ /^(\d)/; say $1 }' 10 11 12 13

        -- Frank

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://737394]
help
Chatterbox?
[erix]: pretty :)
[Your Mother]: Yep, LanX, here is the reverse operation: perl -CSD -MEncode -MMIME::Base64 -E 'say decode_utf8( decode_base64(" 4oGZ"))'
[LanX]: Thanks Many thanks YM... it was already supposed to be encoded, I'll see tomorrow
[Your Mother]: I am entirely skeptical the wall will happen… but this country does love its boongdoggles now and then. :P
[Your Mother]: Did I tell or show you? There is a leucistic Turkey Vulture around here all the time. I have a couple decent pictures.
[Your Mother]: Pure white (well, dirty white :P)
[erix]: as a kid I had a painted bunting -- beautiful
[Your Mother]: I would love to see one. It would be a lifer.
[Your Mother]: Wait… maybe I did see one last year…
[Your Mother]: I saw what I thought was a Cuban trogon but they are too impossibly rare / never seen in the US. That guy might have been what I actually saw.

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2017-01-20 01:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (173 votes). Check out past polls.