in reply to Question about map function [ANSWERED]
You can perfectly sort "YYYY.MM.DD" values as strings with cmp. You don't need to strip dots. So the foreach loop doesn't needed at all.
Update: but if you want numeric than
my @records = map { $_->[0] } sort $sort_routine map { $_->{'date'} =~ /(\d+)\.(\d+)\.(\d+)/; [ $_ +, $_->{'title'}, $1.$2.$3 ] }
or shorter:
my @records = map { $_->[0] } sort $sort_routine map { [ $_, $_->{title}, join '', $_->{date} =~ /\d+/g ] }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Question about map function [SOLVED!]
by automandc (Acolyte) on Nov 17, 2008 at 20:13 UTC | |
by runrig (Abbot) on Nov 17, 2008 at 20:36 UTC |