in reply to Re^4: Date/Time Manipulation
in thread Date/Time Manipulation

Hi RobertJ,

The regex picks those two digits because they're the only ones preceded by a space.

As for the rest: because the /e modifier is used on the substitution, the replacement part is evaluated as a Perl expression. sprintf is documented in sprintf: the first argument is the format specifier, in this case %i, aka %d: "a signed integer, in decimal", where 2.2 specifies a minimum width of 2 and a precision of 2 (personally, I would have written it as %02d, TIMTOWTDI). As for the argument to be formatted, $1 refers to the first capture group of the regex, in this case the two digits of the hour, from which 1 hour is subtracted. The formatted string returned by sprintf is then used as the substitution.

Hope this helps,
-- Hauke D

Replies are listed 'Best First'.
Re^6: Date/Time Manipulation
by RobertJ (Acolyte) on May 25, 2016 at 19:22 UTC

    Didn't notice the space (it is an actual character).

    The rest I was able to figure out from O'Reilley and a little Googling.

    Thanks for reminding me that " " is a character.