Don't ask to ask, just ask | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
s/PATTERN/REPLACEMENT/msixpodualngcer:
>> e Evaluate the right side as an expression. The whole right side of the regex is evaluated. You can't make some parts of the REPLACEMENT evaluated and some not. So you should wrap "$3-" and "-$2" in doublequotes and join all parts by concatenation, e.g.: $date =~ s/(\d+)-(\d+)-(\d+)/ "$3-" . sprintf("%02d",$1) . "-$2" /ge; Upd. You need double quotes to interpolate $3 and $2 (single quotes won't). In reply to Re: Using sprintf in regular expreession.
by rsFalse
|
|