in reply to Working With Arrays and Files
That may seem pretty complicated if it's your first Perl program. In order to understand exactly what's going on, try reading perlref and perldata to understand more about complicated data structures.my %hash; while (my $line = <TEMP>) { chomp($line); my @columns = split ' ', $line; # Add an array of the first four columns to the hash # entry for this type (the type is $columns[5]). Each # hash entry is itself an array of these arrays. push @{$hash{$columns[5]}}, [ @columns[0..4] ]; } # Go through the type names in order, printing out all the # data that was seen with each type foreach my $type (sort keys %hash) { print "$type\n"; foreach my $line (@{$hash{$type}}) { print "@$line\n"; } }
-- Mike
--
just,my${.02}
|
|---|