Re: Regex replacement via external command

Discussion in 'Perl Misc' started by George Mpouras, Jan 22, 2014.

  1. Στις 22/1/2014 16:31, ο/η * Tong * έγÏαψε:
    > On Wed, 22 Jan 2014 06:25:18 +0000, Tim McDaniel wrote:
    >
    >> Don't do `...` when there may be a lot of output. Please see the
    >> perlopentut man page, specifically "pipe open", and don't try to pass
    >> long values on the command line.

    >
    > The problem I was dealing with is, I need to pick out a big chunk of
    > input string (>200K, by regex), feed it to external program (which is
    > pipe after pipe after pipe), then replace the matching string with the
    > processed result. what's the proper way to do it (for big matching
    > chunks)?
    >
    > A thousand time over-simplified version is:
    >
    > perl -e 'print("aa". "x" x 238565 . "bb", "\n")' > HttpBody
    > <HttpBody perl -n000e 's,(x+),`echo $1 | wc -c`,eg; print'
    >
    > The problem is that I not only need to process this big chunk of
    > matching string via the external program, but I also need to replace the
    > matching string with the result of the external process. Putting two
    > together is where the problem for me.
    >
    > Please help.
    >
    > Thanks
    >



    here you go , do something like similar (no size limit)


    perl -e 'while(<>) { s/aa/bb/; print }' HttpBody
    George Mpouras, Jan 22, 2014
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    731
    Reedick, Andrew
    Jul 1, 2008
  2. Anthony Roy
    Replies:
    7
    Views:
    208
    A. Sinan Unur
    Mar 4, 2005
  3. Rainer Weikusat

    Re: Regex replacement via external command

    Rainer Weikusat, Jan 22, 2014, in forum: Perl Misc
    Replies:
    2
    Views:
    73
    Rainer Weikusat
    Jan 23, 2014
  4. Charles DeRykus

    Re: Regex replacement via external command

    Charles DeRykus, Jan 23, 2014, in forum: Perl Misc
    Replies:
    2
    Views:
    62
    Charles DeRykus
    Jan 23, 2014
  5. Rainer Weikusat

    Re: Regex replacement via external command

    Rainer Weikusat, Jan 23, 2014, in forum: Perl Misc
    Replies:
    1
    Views:
    63
    Rainer Weikusat
    Jan 23, 2014
Loading...

Share This Page