--- Harry Putnam <[EMAIL PROTECTED]> wrote:
> Something I'm messing with today and can't get right. I've presented
> a simplified version of what I'd like to do. It amounts to setting
> the strings inside a s/some_re/some_rep/ type action.
>
> I can get it to work fine if both elements are simple and don't
> involve grouping and back reference. But grouping and back reference
> would make my script (the real one ) considerably more versatile.
You just needed an eval().
This works:
#!/dart03/users/bin/perl -wp
BEGIN { our($in,$out,$arg) = (shift,shift,shift||'') }
eval "s/$in/$out/$arg";
The -p means print each line after processing; it puts the input from
STDIN into $_. The BEGIN{} block gets your arguments, and I allowed for
a third to place modifiers such as g or e, but made sure it was defined
with at least an empty string with shift||''. The eval puts the pieces
into working order. :)
Paul
__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]