[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] calculation in replacement string



At 16:08 96-03-14, Peter Folk wrote:

>I need to do a search and replace, replacing on a function of one of the
>matched regexps...  Eg:
>
>s/^([^:]*)/${$1+4}/;
>
>to change "84:thingies" to "88:thingies".  Anybody got any ideas?

Use the 'e' modifier and drop the leading $ in the replacement:
    s/^([^:]*)/ $1 + 4 /e;

--Hal
Hal Wine <hal@dtor.com>     voice: 510/482-0597