in reply to A hash of lists
you are really giving @test scalar context. That's why $new[0] the second time returned 3 - that's the number of elements in @test. Basically, you can't just lay these data structures on top of each other.$bits{'one'}=@test;
\@test is a reference to test, and @{$bits{'one'}} accesses the reference ($bits{'one'}) and the @{} dereferences it. Have you tried perlreftut?my @test = ( qw / bing bong bang / ); print '['.$test[2].'] ['.$test[1].'] ['.$test[0]."]\n"; $bits{'one'}= \@test; my @new = @{$bits{'one'}}; print '['.$new[2].'] ['.$new[1].'] ['.$new[0]."]\n"; OUTPUT: [bang] [bong] [bing] [bang] [bong] [bing]
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: A hash of lists
by sauoq (Abbot) on Nov 06, 2003 at 05:42 UTC | |
by wolis (Scribe) on Nov 06, 2003 at 22:42 UTC | |
by jweed (Chaplain) on Nov 06, 2003 at 23:09 UTC | |
by QM (Parson) on Nov 06, 2003 at 23:41 UTC |