in reply to Print about all elements of the array.

How about this:

use warnings; use strict; my @dates = qw(02/01/2009 01/31/2009 01/01/2009 01/31/2009 02/20/2009 02/20/2009 02/20/2009 02/20/2009 02/01/2009 ); my %dates; $dates{$_}++ for @dates; print map { "$dates{$_} times $_\n" } sort { $dates{$b} <=> $dates{$a} } keys %dates;

Replies are listed 'Best First'.
Re^2: Print about all elements of the array.
by Anonymous Monk on Feb 24, 2009 at 03:46 UTC
    What about this one:

    my @ndates = qw( 02/01/2009 01/31/2009 01/01/2009 01/31/2009 02/20/2009 02/20/2009 02/20/2009 02/20/2009 02/01/2009 ); my %counts = (); for (@ndates) { $counts{$_}++; } foreach my $keys (sort keys %counts) { print "\n\n$counts{$keys}= $keys\n"; }