in reply to Re: Sort directories by date
in thread Sort directories by date
Update: fixed a mistake (missing reverse) in the my $date = ... code line above. Thanks to poj for pointing out the error.#!/usr/bin/env perl use strict; use warnings; use feature qw (say); my @dates = qw{ 12112014 01052015 02202015 03102015 01012011 04092015 09092015 }; my $max_date = 0; my $result; for (@dates) { my $date = join "", reverse unpack q(a4a4); $result = $_ and $max_date = $date if $date > $max_date; } print $result;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Sort directories by date
by karlgoethebier (Abbot) on Sep 30, 2015 at 10:16 UTC |