Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

(nearly) readonly globals

by haoess (Curate)
on Jan 19, 2009 at 20:12 UTC ( #737393=perlquestion: print w/replies, xml ) Need Help??
haoess has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I played a little bit with the vars listed in perlvar, and there are some inconsistent behaviours (using v5.10.0). Before filling a bug report, I would like to discuss these issues:

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

$$ is listed as read-only.

Same is for other special globals like $], $^{TAINT}, $^{UNICODE}, and $^V.

Is there a bug? Are the docs ambiguous?

-- Frank

Replies are listed 'Best First'.
Re: (nearly) readonly globals
by BrowserUk (Pope) on Jan 19, 2009 at 20:18 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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://737393]
Approved by almut
help
Chatterbox?
[Discipulus]: good morning monks
[choroba]: Morning!
[Corion]: Hi choroba, Discipulus!
[Corion]: Yesterday I've been mulling over how to best generate HTTP requests from permutations of values but I haven't found a nice API for passing in the "template" of the HTTP request yet. I guess I'll have to do a SoPW for that

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




    Results (152 votes). Check out past polls.