You've got a good start! What you'll probably want to do is create a hash with the 6th column as keys and the other columns as values. It might end up being a Hash of Arrays of Arrays, like this:
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"; } }
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.

-- Mike

--
just,my${.02}


In reply to Re: Working With Arrays and Files by thelenm
in thread Working With Arrays and Files by kevinw

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.