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