On Tue, Jul 28, 2009 at 15:50, John W. Krahn<jwkr...@shaw.ca> wrote:
snip
> local() only works on variables that are in the symbol table, in other words
> package variables.  All variables that are a single puntuation character are
> package variables and some are global and effect all packages.  local() does
> not create a variable it just masks the current value of a variable within
> the current scope.
snip

And anything called from the current scope, so the code below prints 10 then 5.

#!/usr/bin/perl

use strict;
use warnings;

sub dynamic {
    our $x;
    print "$x\n"
}

{
    our $x = 5;

    {
        local $x = 10;
        dynamic();
    }

    dynamic();
}






>>>>>> Oddly, perl won't let me do "my ($_) = shift;", so I'm stuck having to
>>>>>> use
>>>>>> another variable.
>>>>>
>>>>> Perl 5.10 *will* let you do "my $_".
>>>>
>>>> Why is perl on OS X still at 5.8.8?  It's free, right?  why wouldn't
>>>> Apple
>>>> include the latest one?  (I know this isn't an Apple list, just
>>>> wondering if
>>>> anyone knows.)
>>>
>>> Perl 5.10 is still at the .0 stage (5.10.0) and a lot of people like to
>>> wait until software has progressed past the .0 phase.
>>
>> Makes sense.  What happened to Perl 5.9?
>
> As of Perl 5.6 the odd numbered versions (5.7 and 5.9) are for development
> only.
>
>
>
>
> John
> --
> Those people who think they know everything are a great
> annoyance to those of us who do.        -- Isaac Asimov
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>



-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to