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

Tony Heal
Pace Systems Group, Inc.
800-624-5999
[EMAIL PROTECTED]
 

> -----Original Message-----
> From: Tony Heal [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, August 21, 2007 8:42 AM
> To: beginners@perl.org
> Subject: RE: regex help
> 
> the list is a list of files by version. I need to keep the last 5 versions.
> 
> Jeff's code works fine except I am getting some empty strings at the 
> beginning that I have not
> figured out.
> 
> Here is what I have so far. Lines 34 and 39 are provide a print out for 
> troubleshooting. Once I get
> this fixed all I
> need to do is shift the top five from the list and unlink the rest.
> 
> #!/usr/bin/perl
> 
> use warnings;
> use strict;
> 
> opendir (REPOSITORY, '/usr/local/repository/dists/');
> my @repositories = readdir (REPOSITORY);
> closedir (REPOSITORY);
> 
> my $packageRepo;
> my @values;
> my @newValues;
> foreach (@repositories)
> {
>       $packageRepo = $_;
>       chomp ($packageRepo);
>       opendir (packageREPO, 
> "/usr/local/repository/dists/$packageRepo/non-free/binary-i386");
>       my @repoFiles = readdir (packageREPO);
>       close (packageREPO);
>       foreach (@repoFiles)
>       {
>               my $fileName = $_;
>               chomp ($fileName);
>               if ( /(.*)(([0-9][0-9])(-special)?\.([0-9])(-)([0-9]*))(.*)/)
>               {
>                       push (@values, $2);
>               }
>       }
>       my %h;
>       foreach (@values)
>       {
>               push (@newValues, $_) unless $h{$_}++
>       }
> foreach (@newValues){print "$_\n";}
>       my @new = map { $_->[0] }
>       sort { $b->[1] <=> $a->[1] }
>       map { [$_,(split/-/)[-1]] }
>       @newValues;
>       print "@new[0..4]\n";
> }
> 
> 
> Or for a line numbered version
> http://rafb.net/p/asqgJo27.html
> 
> Tony Heal
> 
> 
> 
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> http://learn.perl.org/



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


Reply via email to