That's incorrect though, since your output shows two copies of  aacs and
brbt ...

Bill

-----Original Message-----
From: Wagner, David --- Senior Programmer Analyst --- WGO
[mailto:[EMAIL PROTECTED] 
Sent: Wednesday, April 05, 2006 5:02 PM
To: Ng, Bill; perl-win32-users@listserv.ActiveState.com
Subject: RE: Efficiency

#!perl
use strict;
use warnings;

my @list = ("aacs1110", "brbt4332", "rtxa4320", "aacs2000", "brig5621",
"brbt5220", "nbvc1111"); my ($mykey, $mypriorkey) = (q[], q[]); my
@finallist = ();

foreach $mykey (sort { $a->[1] cmp $b->[1] ||
                       $b->[2] <=> $a->[2]
                      }
                    map{[$_, /^(.{4})(.{4})/ ]}
                    @list) {
    next if ( $mykey->[0] eq $mypriorkey);
    push(@finallist, $mykey->[0]);
    $mypriorkey = $mykey;
 }
print join("\n", @finallist);

Output:
aacs2000
aacs1110
brbt5220
brbt4332
brig5621
nbvc1111

A few more lines, but I like to be able to read the lines.

Wags ;) ps Only one pass through the data.

_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to