Forum Moderators: coopster & phranque
$a = '7 PM'; $a =~ s/\b(\d\d?)\s+([AP]M\b)/$2 eq 'PM'? $1+12 : $1/eg; print "$a\n";
# Handle am/pm:$time_string =~ s/am//i or $time_string =~ s/(\d+?)(:.+¦)pm/($1+12).$2/ei;
Be sure to replace ¦ with the real pipe symbol (copy/paste will break the code!) It gets converted by forum software for some obscure reason.