Ng, Bill wrote:
> 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;
        need to be:
    next if ( $mykey->[1] eq $mypriorkey);
    push(@finallist, $mykey->[0]);
    $mypriorkey = $mykey->[1];

Sorry about that.
Output is then:
aacs2000
brbt5220
brig5621
nbvc1111

Wags ;)

>  }
> 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.



*******************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
*******************************************************


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

Reply via email to