Hi Paul,

Ihashes would need a little bit of work to work with this, as you will have 
multiple entries with the same key, eg you have three lines beginning "123".
if you have all you lines in an array, you could do this:

foreach $line (sort @arry) {
     die "Invalid input: $line\n" unless ($line =~ /^(\S+)\s*(\S.*)$/);
     $MyHash{$1} = $2;
}

# then you can dump them like this...

foreach (sort keys %MyHash) {
     print "$_:\t$MyHash{$_}\n";
}

R

At 21:36 30/09/2002 -0400, Paul and Joann Van Dalen wrote:
>Hi all,
>
>Given an input file that has the following records:
>
>123    ABC    XX112    YYYY    Zzzzzzzzzz
>123    DEF    XX113    WWWW    Zzzzzzzzz
>123    EEF    XX112    YYYY     Zzzzzzzzzz
>444    ccc    vvbfd    QQQQ    ccccccccc
>444    CCd    vvbfd    QQQQ    ccccccccc
>444    ddd    ssddd    QQQQ    xxxxxxxx
>
>I need to focus on the first column (the input file is already sorted on
>that field) and, grouped by the first column, pull out
>the first record of that group.
>e.g., I would need to have the following from the above as output:
>
>123    ABC    XX112    YYYY    Zzzzzzzzzz
>444    ccc    vvbfd    QQQQ    ccccccccc
>
>I believe I'd need something like a hash, where for every record within
>a group defined by the common value of the first column, I take the
>numerically first occurance of that group, but I don't know how to do
>that in Perl.  Would it take a loop for each group within the loop for
>the entire file??
>
>Thanks very much,
>Paul
>
>
>
>--
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to