Cool!  15 years of perl and I never used /e

I got the regexp to convert the first file
and discovered that sprintf is way more inconvenient
than I remember. It doesn't return the string,
it returns pass/fail. And it operates on char* ?

This may have been why I used boost::format.

Anyone know of a c++ self contained function that takes
a format string and returns the result string
rather than using char*'s and returning the value in
a char*?

It's always something.

Greg



On Fri, April 3, 2015 8:25 pm, Uri Guttman wrote:
> 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
>
>


-- 



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

Reply via email to