On 04/03/2015 08:59 PM, Greg London wrote:
s/format\((.*?)\)(.*?)\.str\(\)/something/g

The problem is I need $1 and $2 to put into sprintf
but I before I do that, I also need to take the '%'
operators in $2 and replace them with ',' and THEN
put it back in.

Things started to get hairy, and I was wondering
if I'm overlooking a solution that would make this
a lot easier.


the /e modifier is your friend. just put the logic to transform the $2 into the replacement section and s/// will use the value of the expression for its replacement. if the code gets too long for the replacement part, call out to a sub instead. for a working example with the sub, look at Template::Simple which uses s///e to replace template markup with recursed calls to the same sub.

uri


_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to