-----Original Message----- >From: Tony Heal <[EMAIL PROTECTED]> >Sent: Aug 21, 2007 5:50 AM >To: beginners@perl.org >Subject: regex help > >I have an array that will have these values. Each value is part of a file >name. I need to keep the highest (numerically) >5 files and delete the rest. What is the easiest to sort the array. >
Well,it can be sorted but follow which field in the filename?the last numerical field? Just show a way, use strict; use warnings; my @arr = qw(14-special.4-32 14-special.4-32 14-special.4-33 14-special.4-33 15-special.1-51 15-special.1-51 15-special.1-52 15-special.1-52 15-special.1-52 15-special.1-53 15-special.1-53 15-special.1-53 15-special.1-54 15-special.1-54 15-special.3-44 15-special.3-44 15-special.3-45 15-special.3-45 15-special.4-4 15-special.4-4 15.2-100 15.2-100 15.2-104 15.2-104 15.2-124 15.2-124 15.2-65 15.2-65 15.2-66 15.2-66); my @new = map { $_->[0] } sort { $b->[1] <=> $a->[1] } map { [$_,(split/-/)[-1]] } @arr; print "@new[0..4]"; -- 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/