To add to Corion's comment the arrays in your original post and in your follow up are different.
It's hard to help if the question keeps moving!
update: the following is wrong :-(
Each element in your follow up array is the reverse of those in the origninal. (There's a hint in there!)
With that observation and another look at the docs I was able to sort the array in the order you're looking for using the method suggested by Corion.
You didn't say my $sort = (... either.
update 2:
Pursuing the reverse theme, perhaps you could consider an intermediate step:
#!/bin/perl5
use strict;
use warnings;
use Data::Dumper;
my @sort = qw(
05-11-2006
01-01-2005
04-12-2005
22-03-2005
);
my @reversed = map {
join '',
substr($_, 6),
substr($_, 3,2),
substr($_, 0,2)
} @sort;
print Dumper(\@reversed);
__DATA__
---------- Capture Output ----------
> "C:\Perl\bin\perl.exe" _new.pl
$VAR1 = [
'20061105',
'20050101',
'20051204',
'20050322'
];
> Terminated with exit code 0.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Outside of code tags, you may need to use entities for some characters:
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
|
|