Hi Monks!
I need to get details on all the elements of an array, like listing all the elements in the array and how many times it shows.
Here is what I have so far, any help will be great!
#!/usr/bin/perl
use strict;
use CGI qw/:standard/;
use CGI::Carp qw(fatalsToBrowser);
print header();
#######test 1
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 %count = ();
my $c=0;
foreach my $date (@dates)
{
$c++;
$count{$date}++;
print "<font size=1>$c</font> - $count{$date} - $date<br>\n";
}
My goal will be to have some thing like this at the end:
4 times 02/20/2009
2 times 02/01/2009
2 times 01/31/2009
1 times 01/01/2009
Thanks for the help!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
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, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
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.