[JOB] Perl Software Developer and Database programmer

Lusercop `the.lusercop' at lusercop.net
Wed Feb 22 12:36:33 GMT 2006


On Wed, Feb 22, 2006 at 12:19:09PM +0000, Andy Armstrong wrote:
> On 22 Feb 2006, at 12:07, Lusercop wrote:
>> this thread. (and given that you can simulate the effects of local with a
>> more explicit set of mys, in a much clearer way, then this is also true).
> What simulation of local are you advocating and why?

{
   my $newdollarslash = "whatIwant";
   my $savdollarslash = $/;
   $/ = $newdollarslash;

   dostuffwithappropriatecalls();

   $/ = $savdollarslash;
}

obviously.

this is the equivalent of:

{
   local $/;

   my $newdollarslash = "whatIwant";
   $/ = $newdollarslash;

   dostuffwithappropriatecalls();
}

Why? because it's clear that you're saving the value and restoring it. For
those in the thread that didn't know that this was what local did, that's
what it does. If the scope is quite long (then you should be splitting it
into separate functions ...) then you are explicitly restoring the value
back. I prefer this, stylewise.

-- 
Lusercop.net - LARTing Lusers everywhere since 2002


More information about the london.pm mailing list