in reply to Can I auto-save and restore global variables?

Hi,

have a look at perldoc -f local. I'm not sure whether you want the following:

use Data::Dumper; $Data::Dumper::blah = 0; # Set defaults $Data::Dumper::fred = 'xyz'; ... if ($i_am_debugging_this_bit) { local $Data::Dumper::blah = 1; # Override these for a bit local $Data::Dumper::fred = 'nerd'; ... }

This should do what you want.

Regards
McA

Replies are listed 'Best First'.
Re^2: Can I auto-save and restore global variables?
by davehorsfall (Novice) on Jul 25, 2014 at 04:54 UTC

    Perfect; that's just what I want! I'd forgotten that "local" did that; I need to temporarily override the values so that for example a 1000-element array doesn't take one line each...

    My Perl is a little rusty after being out of the workforce for a few years now, so I thought I'd brush up by writing a script that solves the "target" puzzle that's syndicated in some papers (and without any false modesty, it's *fast*).

    Thanks.