Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Error: Can't use global $^W in "my"

by dsb (Chaplain)
on Jul 08, 2004 at 17:17 UTC ( [id://372863]=note: print w/replies, xml ) Need Help??


in reply to Error: Can't use global $^W in "my"

You cannot use my to declare any of the magical built-in variables Perl has.

If you want to modify the value of a built in, you must use local to do it, and then the modification will be local to the enclosing code block.

Update: Time to revisit local :)


dsb
This is my cool %SIG
  • Comment on Re: Error: Can't use global $^W in "my"

Replies are listed 'Best First'.
Re^2: Error: Can't use global $^W in "my"
by calin (Deacon) on Jul 08, 2004 at 17:55 UTC
    If you want to modify the value of a built in, you must you local to do it, and then the modification will be local to the enclosing code block.

    A better approach, which doesn't suffer from the problems of dynamic scoping with local, would be to use the lexically scoped (no) warnings pragma instead for this particular situation - see perllexwarn

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (None)
    As of 2024-04-25 00:55 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found