[Top][All Lists]

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

Re: Replacement strings

From: Ole Tange
Subject: Re: Replacement strings
Date: Wed, 25 Jun 2014 23:53:27 +0200

On Wed, Jun 25, 2014 at 7:17 PM, Cook, Malcolm <> wrote:

> Given that your implementation is in Perl, you might consider extending the 
> syntax to allow
>         any Perl expression can appear between the braces
>         the expression is evaluated in the context where $_ is bound to the 
> (chomped) current line of input.
> Then you could write, for example:
> example                 current syntax          meaning / note
> {$_}                            {}                      the current line
> {s/(\.[^.]+$){2}//}                     {.}                     the current 
> line after trimming exactly two extensions
> {s/(\.[^.]+$){,2}//}                    {.}                     the current 
> line after trimming up to two extensions

We need a way so that I can still write a one-liner in Perl:

       find . -type f -print0 | parallel -q0 perl -i -pe
'if(/quux/){s/FOO BAR/FUBAR/g}'

That should not be parsed by GNU Parallel, because I actually do that sometimes.

So instead it could be {{perl expression}}. I don't think the {{...}}
is something you would otherwise write on the command line.

- o -

Right now the replacement strings are fixed strings. So some of the
core of GNU Parallel will have to be ripped out. It might be easy it
might be horrible. But that is my worry.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]