-----Original Message-----
>From: Tony Heal <[EMAIL PROTECTED]>
>Sent: Aug 21, 2007 9:25 PM
>To: [EMAIL PROTECTED], beginners@perl.org
>Subject: RE: regex help
>
>Here is a sample of the versions that I am using.
>16.1-17
>16.1-22
>16.1-23
>16.1-39
>16.3-1
>16.3-6
>16.3-7
>16.3-8
>16.3-15
>16.5-1
>16.5-2
>16.5-10
>16.5-13
>15.3-12
>15.2-108
>14-special.1-2
>14-special.1-8
>14-special.1-15
>14-special.2-40
>14-special.2-41
>14-special.3-4
>14-special.3-7
>14-special.3-12
>15.2-110
>15.2-111
>15-special.1-52
>15-special.1-53
>15-special.1-54
>16-special.4-9
>16-special.4-10
>16-special.5-1
>16-special.5-2
>16-special.6-6
>

Ok try this way.It sort the version from high to low and output the first 5.

use strict;
use warnings;

my @arr = qw(16.1-17
16.1-22
16.1-23
16.1-39
16.3-1
16.3-6
16.3-7
16.3-8
16.3-15
16.5-1
16.5-2
16.5-10
16.5-13
15.3-12
15.2-108
14-special.1-2
14-special.1-8
14-special.1-15
14-special.2-40
14-special.2-41
14-special.3-4
14-special.3-7
14-special.3-12
15.2-110
15.2-111
15-special.1-52
15-special.1-53
15-special.1-54
16-special.4-9
16-special.4-10
16-special.5-1
16-special.5-2
16-special.6-6
);

my @new = map { $_->[0] } sort { $b->[1] <=> $a->[1] or $b->[2] <=> $a->[2] or 
$b->[3] <=> $a->[3] } map { [ $_, split/\D+/ ] } @arr;
print "@new[0..4]";

__END__

Good luck!

--
Jeff Pang - [EMAIL PROTECTED]
http://home.arcor.de/jeffpang/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to