[JOB] Perl Software Developer and Database programmer
Jonathan McKeown
jonathan at hst.org.za
Wed Feb 22 13:12:36 GMT 2006
On Wednesday 22 February 2006 14:36, Lusercop wrote:
> On Wed, Feb 22, 2006 at 12:19:09PM +0000, Andy Armstrong wrote:
>
> > What simulation of local are you advocating and why?
>
> {
> my $newdollarslash = "whatIwant";
> my $savdollarslash = $/;
> $/ = $newdollarslash;
>
> dostuffwithappropriatecalls();
>
> $/ = $savdollarslash;
> }
And you have to remember to set it back at the end. Why not let perl remember
for you?
{
local $/ = "whatIwant";
dostuffwithappropriatecalls();
} # everything is back as before
If you want to localise a value, don't use a ``global'' assignment and make
the maintenance programmer search for the other half of your intention: use
the facility the language provides, and put the information in one place.
my localises a name in space; local localises a value in time. There are two
keywords because these are two different things.
Jonathan
More information about the london.pm
mailing list