in reply to Re: Slurping search-replace patterns from a file
in thread RESOLVED: Slurping search-replace patterns from a file

Because your input file appears to contain perl code, I suspect you can get by with eval:

Unfortunately, it's not quite that simple. I provided an overly simplified example - it's usually not that clean. This is more along the lines of what my file looks like:

replace { (foo) and stuff } with { bar $1 }

Which will be programmatically consolidated to:

s/(foo) and stuff/bar $1/

I'd like to avoid debating the format, which is why I provided the simplified example.

All the same, thanks for pointing out that an eval would work in the original situation.

-HKS

Replies are listed 'Best First'.
Re^3: Slurping search-replace patterns from a file
by jettero (Monsignor) on Oct 14, 2008 at 16:43 UTC
    Eval may still be the way to go though...
    # rip stuff from file eval "$wahtever =~ s/$lhs/$rhs/; 1" or die $@;
    The /ee stuff is essentially the same as that (in the sense that it has to run eval() on the rhs... I fail to see how you'll preserve the meaning of $1 without an eval or /ee.

    -Paul