emilford has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to create an array of arrays using array references. I think I've
narrowed the problem down. When I attempt to print out the array of arrays,
I get the same data for each array reference. I printed out all of the
reference numbers to arrays and they were all the same.
Maybe my code will help explain:
foreach my $file (@homes) { open(HOUSE, "<$base_directory/homes/$file") || die &show_error("Unab +le to open file in sort routine"); @home = <HOUSE>; close(HOUSE); # create array of arrays chomp(@home); push @sorted, \@home; }
When I print the references stored in the array, i get ARRAY(0x8108f20) ARRAY(0x8108f20) ARRAY(0x8108f20). How do I get this code to create different array references, so that when I go to use the data, I get different information each time through. Basically, N different array references based on what is read in from "$file". Hope this makes sense.
Edit ar0n -- wrapped code in code tags
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: help with array of arrays
by gav^ (Curate) on Apr 01, 2002 at 01:58 UTC | |
|
Re: help with array of arrays
by PrimeLord (Pilgrim) on Apr 01, 2002 at 02:06 UTC | |
|
Re: help with array of arrays
by emilford (Friar) on Apr 01, 2002 at 02:36 UTC | |
by Chmrr (Vicar) on Apr 01, 2002 at 02:43 UTC | |
by gav^ (Curate) on Apr 01, 2002 at 02:47 UTC | |
|
Re: help with array of arrays
by emilford (Friar) on Apr 01, 2002 at 03:05 UTC | |
|
Re: help with array of arrays
by indapa (Monk) on Apr 01, 2002 at 18:15 UTC |