I'm parsing time from a last output. I got an unexpected input, so getting an unexpected output shouldn't be surprising, but for the life of me I can't figure out what perl is doing.
subroutine is
sub minutes {
my $time = shift;
print "minutes handed $time " if $DEBUG_MINUTES;
if ( $time =~ /(\d+):(\d+)/ ) {
print "Interpreted as $1 hours $2 mins\n" if $DEBUG_MINUTES;
return 60 * $1 + $2;
} elsif (/(\d+)+(\d+):(\d+)/) {
print "Interpreted as $1 days, $2 hours, $3 minutes\n" if $DEBUG_M
+INUTES;
return ( 24 * $1 + $2 ) * 60 + $3;
} else {
warn "I don't understand time $time\n";
return $time;
}
}
I was processing a line
archerh Thu Jun 22 10:25 - down (-6+-1
+2:-52)
and I get
minutes handed -6+-12:-52 Interpreted as 1 days, 0 hours, 25 minutes
How does \d+ do this?