Just how tied to the hash are you? Assuming you have a function call such as:
myfunc($ts, $interval), then something like the following might also be worth considering:
sub myfunc {
my ($ts, $interval) = @_;
my $minute;
#
# Somehow get $minute from $ts,
# using the method of your choice.
#
# Ex., using the method in the OP...
$minute = substr($ts, 10, 2);
return $interval * int($minute / $interval);
}
as it appears to provide the same results you seek, but perhaps with a little less brain-damage....
Hope that helps.