Hi!
I have the following problem. As input data I have an array of
filenames, ie:
@files_a = qw(file1a.ext file1.ext file1m.ext file1g.ext)
@files_b = qw(file2w.ext file2a.ext file2z.ext file2b.ext file2.ext
file2x.ext file2y.ext file2c.ext)
What I need to is sort the arrays by the versions (the files I have been
presented with use alphabetical versioning, ie. no letter means
original, then versions go as a, b, c, ...). That is not a problem. The
problem I have is when instead of an array @files_a I get one like
@files_v, which contains letters from the end of the alpahbet and the
beginning, which should mean that the users ran out of letters and began
from a, b, ... again. I am at a loss how to sort an array like @files_b
without making it overly complicated (I have an idea in mind, with a few
if's and else's and comparisons and stuff :) ). I have looked at some
sort modules but I only have the out-of-the package ActivePerl
installation to work with, with no option to install additional modules.
The desired sort order would be something like:
- first the file without the version letter, ie. ends with a number (if
it exists)
- then a-z
In case of @files_b like arrays:
- first the file without the version letter (if it exists)
- then versions from the last part of the alphabet
- versions from the first part of the alphabet
The desired sort order of the @files_b array would be:
file2.ext
file2w.ext
file2x.ext
file2y.ext
file2z.ext
file2a.ext
file2b.ext
file2c.ext
There can be "holes" in versions (ie. a, b, e, f) but not very likely.
The versionless files often do not exist but I need to take them into
consideration in case if they do.
Before I go and implement my idea, I would like to ask you for any
advice what to do in order to achieve what I need, where to find more
information on sorting, etc.
Thank you in advance,
Miha
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs