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

Re: [MacPerl] Evaluating expressions with regexp



>  I want to evaluate expressions in an text, the expressions are in the form:
>  <#execute:(expression)#>, like <#execute: 933.47+273#>.
>
>  I am using "s/<#execute:(.*?)#>/\1/goe" to find and evaluate this and
>  it works -- kind of.
>  Problem is it evaluates to "SCALAR(0x8b9159c)" instead of just 
>plain "1206.47".

Thanks everyone that came up with the solution!

I wish BBEdit would use the same regexp syntax as Perl! Of course it 
should be $1 -- I'm using BBEdit to edit Perl (which uses \1), 
sometimes I forget the differences... I was close to the solution 
(and as a newbie this makes me proud :-), but of course 
s/<#execute:(.*?)#>/\1/gee didn't work...

The correct regexp is:
s/<#execute:(.*?)#>/$1/gee

Lesson learned: use -w!

/Peder

Peder Axensten
mailto:f95-pax@nada.kth.se (Umea, Sweden)

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org