Sorry, I am still very busy. And looking quickly over the code, it is
a little tricky to determine the latest one since the pattern of the
filename is so arbitrary. However, if you use a Path::Class::Versioned
pattern that is sortable, for instance, something like:
my $v = Path::Class::Versioned->new(
version_format => '%03d',
name_pattern => [ undef, '-File.txt' ],
parent => $dir
);
Which will produce file names like so:
001-File.txt
002-File.txt
003-File.txt
004-File.txt
Then you can sort the files in the directory and find the latest like
this:
my $dir = Path::Class::Dir-
Show quoted text >new( $directory_where_files_are_located );
my @files = grep { $_->isa('Path::Class::File') } $dir->children;
my @sorted_files = sort { $a->basename cmp $b->basename } @files;
my $latest = pop @sorted_files;
You can likely put this into a subroutine for use within your
application.
Hopefully this helps.
- Stevan
On Jan 26, 2011, at 9:06 AM, Meir Guttman via RT wrote:
Show quoted text> Queue: Path-Class-Versioned
> Ticket <URL:
http://rt.cpan.org/Ticket/Display.html?id=64183 >
>
> Dear Steven,
>
> So far I could determine what is the current version using other
> means. But
> now I am doing a file Read-Modify-Write application that should
> preserve all
> previous file versions. The Path::Class::Versioned would be the
> right and
> coolest way to go.
> Are you less pressed now than before the holidays...?
> Best regards,
> Meir
>
>
>
> -----Original Message-----
> From: Stevan Little via RT [mailto:bug-Path-Class-Versioned@rt.cpan.org
> ]
> Sent: Friday, December 24, 2010 12:06 AM
> To: meir@guttman.co.il
> Subject: [rt.cpan.org #64183] Add "->latest_xxx" methods
>
> <URL:
https://rt.cpan.org/Ticket/Display.html?id=64183 >
>
> Sure that would work, you are welcome to whip up a patch to do that
> if you
> want, I am currently too busy with work and the holidays to get it
> right
> now.
>
> - Stevan
>
>
>
>