in reply to Re: An eighth use of local
in thread An eighth use of local
In the subroutine show, local is used to temporary set the value of the second element to something else. Upon leaving the block, the old value is restored.#!/usr/bin/perl use strict; use warnings; my @things = qw /foo bar baz/; sub do_print { print "@things\n"; } sub show { local $things[1] = 'qux'; do_print; } show; do_print; __END__ foo qux baz foo bar baz
This is not mentioned in Dominus' article, and this is what rinceWind is using. The fact that %ENV is special is irrelevant.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: An eighth use of local
by xdg (Monsignor) on Dec 01, 2005 at 16:51 UTC | |
|
Re^3: An eighth use of local
by ikegami (Patriarch) on May 19, 2006 at 16:33 UTC | |
|
Re^3: An eighth use of local
by itub (Priest) on Dec 02, 2005 at 02:04 UTC |