"Use a nested hash", I thought. It's one of those thoughts that sounds like it offers a neater solution than it does. This does the job, but it's a
little contrived. Having said that, once you've got the stuff into the data structure you may find there are lots of other great things you can do with it, so there may be some merit here that I haven't spotted. See how you like:
my %sort;
for (<DATA>) {
m!(\d+)(\D+)(\d+)(\D*)R(\d+)B?(\d*)\.(\w+)$!;
$sort{$7}{$6}{"$1$2"}{$3}{$5}{$4} = $_;
}
for my $first (sort keys %sort) {
for my $second (reverse keys %{$sort{$first}}) {
for my $third (sort keys %{$sort{$first}{$second}}) {
for my $fourth (sort keys %{$sort{$first}{$second}{$third}
+}) {
for my $fifth (sort keys %{$sort{$first}{$second}{$thi
+rd}{$fourth}}) {
for my $sixth (sort keys %{$sort{$first}{$second}{
+$third}{$fourth}{$fifth}}) {
print $sort{$first}{$second}{$third}{$fourth}{
+$fifth}{$sixth};
}
}
}
}
}
}
This prints out
18AD13XR0B3.ras
18DD13AR0B2.ras
5A344R2B15.ras
13B29AR0B1.ras
113A22R1.ras
113A29R0.ras
113A29AR0.ras
113B28R2.ras
5A32R0.ras
5A33R0.ras
5A34R0.ras
5A35R0.ras
5A35SR0.ras
18AD13XR0B3.vec
18DD12YR0B2.vec
18DD13AR0B2.vec
5A344R2B15.vec
113B29AR0B1.vec
113A22R1.vec
113A28R0.vec
113A28AR0.vec
113A28R1.vec
113A28R2.vec
113A28AR2.vec
113A29R1.vec
113A29AR2.vec
5A32R0.vec
5A33R0.vec
5A34R0.vec
5A35R0.vec
... if that's not exactly what you wanted, you can probably tweak the code. And maybe some greater monk than I can make the recursive unpacking of the hash a bit shorter.
Merry Christmas!
§
George Sherston