> > Er? Sorry, I don't mean for this to sound as bad as it does,
> > but have you read the docs that *come* with Perl
>
> i will let you take a guess.
Hmm...that sounded even worse than I thought it would.
Again, a serious apology. I *really* didn't mean for it to, lol
The discussion
On Wednesday 19 February 2003 08:16, Paul wrote:
>
> Er? Sorry, I don't mean for this to sound as bad as it does, but
> have you read the docs that *come* with Perl
i will let you take a guess.
>
> Perhaps a mistaken assumption. Could someone delineate the difference
> between package va
> >> there is no package variables in Perl, only global or lexical.
> >
> > Not so -- ALL package variables in Perl *are* global, but likewise
> > all global variables in Perl are package vars. Even $_ is
> > technically $main::_ so that
> >
> > $_ = 'foo';
> > package bob;
> > print $main:
David wrote:
>
> Paul wrote:
> >
> > Not so -- ALL package variables in Perl *are* global, but likewise all
> > global variables in Perl are package vars. Even $_ is technically
> > $main::_ so that
> >
> > $_ = 'foo';
> > package bob;
> > print $main::_."\n";
> >
> > prints "foo" and the ne
Paul wrote:
>> > Lexicals aren't in the symbol table.
>> > my $foo;
>> > *can't* be accessed as $pack::foo, because it isn't IN a package.
>>
>> true.
>>
>> > Locals, on the otherhand, *have* to be package variables that can
>> > be tracked by $pack::foo syntax. So how can
>> > my @bar;
>> >
> > Lexicals aren't in the symbol table.
> > my $foo;
> > *can't* be accessed as $pack::foo, because it isn't IN a package.
>
> true.
>
> > Locals, on the otherhand, *have* to be package variables that can
> > be tracked by $pack::foo syntax. So how can
> > my @bar;
> > allow
> > local $bar
--- Jenda Krynicky <[EMAIL PROTECTED]> wrote:
> From: Paul <[EMAIL PROTECTED]>
> > --- david <[EMAIL PROTECTED]> wrote:
> > > Paul wrote:
> > > > @a = 'A'..'Z';
> > > > { my @a = (0..9);
> > > > { local $a[3] = 'foo';
> > > > print join '|', @a, "\n";
> > > > }
> > > > print
From: Paul <[EMAIL PROTECTED]>
> --- david <[EMAIL PROTECTED]> wrote:
> > Paul wrote:
> > > @a = 'A'..'Z';
> > > { my @a = (0..9);
> > > { local $a[3] = 'foo';
> > > print join '|', @a, "\n";
> > > }
> > > print join '|', @a, "\n";
> > > }
> > > print join '|', @a, "\n";
>
Paul wrote:
>
> Lexicals aren't in the symbol table.
>
> my $foo;
>
> *can't* be accessed as $pack::foo, because it isn't IN a package.
>
true.
> Locals, on the otherhand, *have* to be package variables that can be
> tracked by $pack::foo syntax. So how can
>
> my @bar;
>
> allow
>
>
--- david <[EMAIL PROTECTED]> wrote:
> Paul wrote:
> > @a = 'A'..'Z';
> > { my @a = (0..9);
> > { local $a[3] = 'foo';
> > print join '|', @a, "\n";
> > }
> > print join '|', @a, "\n";
> > }
> > print join '|', @a, "\n";
> >
> > prints
> > ==
> > 0|1|2|foo|4|5|6|7|8|
Paul wrote:
> @a = 'A'..'Z';
> { my @a = (0..9);
> { local $a[3] = 'foo';
> print join '|', @a, "\n";
> }
> print join '|', @a, "\n";
> }
> print join '|', @a, "\n";
>
> prints
> ==
> 0|1|2|foo|4|5|6|7|8|9|
> 0|1|2|3|4|5|6|7|8|9|
> A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R
Again, from perlsub
Under
When to Still Use local()
3. You want to temporarily change just one element of an
array or hash.
You can "local"ize just one element of an aggregate.
Usually this is done on dynamics:
{
local $SIG
12 matches
Mail list logo