in reply to extracting by date into hour for counting
use strict; my %byhour; my @hours = ( '2005-02-01 14:35:24','2005-02-01 10:35:24', '2005-02-01 14:35:24','2005-02-01 23:35:24', '2005-02-01 12:35:24'); foreach (@hours) # Use default variable $_ { /\s(\d\d)/; # Regex operates on $_ by default $byhour{$1}++; # Will create hash element if needed } foreach (0..23) { printf "%2d had %d\n", $_, $byhour{$_}}
|
|---|