Had you been using strict & warnings, perl would have informed you that "Multidimensional syntax $count_message[$hh1,$mm1] not supported".
In Perl multidimensional arrays (aka array of arrayrefs) are written:
$count_message[$hh1][$mm1]++;
However, I think you'd be better off using hashes:
use Data::Dumper; my %msg_rate = ('1', '00:00:00,284', '2', '00:00:00,462', '3', '01:01: +00,462', '4', '00:02:00,462', +'5', '01:03:00,462'); my %count_per_min; while( my ($key1, $val1) = each(%msg_rate) ) { my ($hh1,$mm1,$ssms1) = split(/\:/,$val1); $count_per_min{"$hh1:$mm1"}++ } print Dumper \%count_per_min;
Output:
$VAR1 = { '00:00' => 2, '00:02' => 1, '01:03' => 1, '01:01' => 1 };
In reply to Re: Count Messages for each minute, 2D array error
by FunkyMonk
in thread Count Messages for each minute, 2D array error
by max210
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |