August 1999 Perl Hardware Store Slide #32

         use Memoize;
         sub compare_dates {
           to_number($a) <=> to_number($b);
         }
         # Convert "Apr 2, 1969" to "196990402"
         sub to_number {
           my ($m, $d, $y) = 
             ($_[0] =~ /(\w{3}) (\d+), (\d+)/);
           sprintf("%04d%02d%02d", 
                   $y, $m2n{$m}, $d);
         }
         memoize 'to_number';


Next Copyright © 1998 M-J. Dominus