in reply to Re: Re: Using list elements within lists contexts with the distributive properties of HTML shortcuts
in thread Using list elements within lists contexts with the distributive properties of HTML shortcuts
If you change the print line to print "$_\n";, you'll see the aliasing in effect. (It doesn't matter whether you use for or foreach, as they're synonyms.)my $list = 'some default item'; my @list = (1, 2, 3, 4); foreach (@list) { print "$list\n"; }
Of course, there's a deeper misunderstanding, namely that declaring a lexical does not create what most people in the know might consider a typeglob (at least, not in a symbol table. It's put in a pad.). Nor are the values pointed to by typeglob slots automatically populated by iterating over an aggregate of the same name.
It is true that when you do cause a new typeglob to be created, it does automagically get a new scalar in the appropriate slot, but that's done as an optimization, and not for any aliasing.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Using list elements within lists contexts with the distributive properties of HTML shortcuts
by Anonymous Monk on Jun 11, 2002 at 06:22 UTC |