in reply to Re: Clearing user defined variables
in thread Clearing user defined variables

He can't "just reset %globals@": the reset takes an argument that is the first letter (or range of first letters) of variable name.

So if he put in reset 'g', it would reset all variables starting with g, including $g, @great, %google, and if he reset 'globals', it would reset all variables starting with a,b,g,l,o or s.

IMHO, reset is bad karma.

Replies are listed 'Best First'.
Re: Re: Re: Clearing user defined variables
by tachyon (Chancellor) on Apr 13, 2004 at 08:09 UTC

    Sorry I was a little unclear. By 'reset' I meant

    %globals = (); # or _init(\%globals);
    or similar not using reset itself. This sort of 'reset' code is found in modules like CGI.pm to reset the globals and is used as a cleanup handler in mod_perl.

    cheers

    tachyon

Re: Re: Re: Clearing user defined variables
by PodMaster (Abbot) on Apr 13, 2004 at 07:53 UTC
    Unless I'm missing something, all reset does is undef a gang of variables at once. All that the OPs snippet does is assigns the nothing string to scalars, and the empty set to arrays, so I guess it'd be
    foreach(keys %globals){ if( ref $globals{$_} eq 'ARRAY' ){ @{ $globals{$_} } = (); } else { $globals{$_} = ''; } }

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.