Regular Expressions :: replacing data
1 # 2 # replace data with the substitution operator: 's' 3 # 4 # s/regex/replacement/ 5 # 6 7 my $string = 'It starts at 9:45am; but it could be 10 a.m. or 11 P.M.'; 8 9 # We want a consistent format, e.g., "11 AM" 10 11 $string =~ s|(\d)\s*([aApP])\.?[mM]\.?|$1 \U$2m|g; 12 13 print $string; 14 15 # outputs 'It starts at 9:45 AM; but it could be 10 AM or 11 PM'