Re: [OT] sys call length limitation

Discussion in 'Perl Misc' started by Rainer Weikusat, Jan 24, 2014.

  1. * Tong * <> writes:
    > On Thu, 23 Jan 2014 14:59:47 +0000, Ben Morrow wrote:
    >
    >>> s,(x+),`echo $1 | wc -c`,eg

    >>
    >> . . . If it's just a Unix filter (input on stdin, output
    >> on stdout) then use tempfiles:
    >>
    >> use File::Slurp qw/read_file write_file/;
    >> use File::Temp qw/tempfile/;
    >>
    >> sub filter {
    >> my ($data) = @_;
    >>
    >> my ($IN, $in) = tempfile; my ($OUT, $out) = tempfile;
    >>
    >> write_file $IN, $data; system "wc -c <$in >$out"; return
    >> read_file $OUT;
    >> }
    >>
    >> s,(x+),filter $1,eg

    >
    > Nice, neat, clear & elegant. We have a winner.


    Make that "Oh my God I got it!".
    Rainer Weikusat, Jan 24, 2014
    #1
    1. Advertising

  2. Rainer Weikusat <> writes:
    > * Tong * <> writes:
    >> On Thu, 23 Jan 2014 14:59:47 +0000, Ben Morrow wrote:
    >>
    >>>> s,(x+),`echo $1 | wc -c`,eg
    >>>
    >>> . . . If it's just a Unix filter (input on stdin, output
    >>> on stdout) then use tempfiles:
    >>>
    >>> use File::Slurp qw/read_file write_file/;
    >>> use File::Temp qw/tempfile/;
    >>>
    >>> sub filter {
    >>> my ($data) = @_;
    >>>
    >>> my ($IN, $in) = tempfile; my ($OUT, $out) = tempfile;
    >>>
    >>> write_file $IN, $data; system "wc -c <$in >$out"; return
    >>> read_file $OUT;
    >>> }
    >>>
    >>> s,(x+),filter $1,eg

    >>
    >> Nice, neat, clear & elegant. We have a winner.

    >
    > Make that "Oh my God I got it!".


    There's, unfortunately, "Scared of People" in front of that, which, while
    a great song, doesn't fit in here, but it can be regarded as a reverse
    bonus track.

    http://www.youtube.com/watch?v=X1KD131sXDs

    "Legally imposed CULTURE-reduction is cabbage brained!"
    Rainer Weikusat, Jan 24, 2014
    #2
    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. Tim McDaniel

    Re: sys call length limitation

    Tim McDaniel, Jan 22, 2014, in forum: Perl Misc
    Replies:
    0
    Views:
    72
    Tim McDaniel
    Jan 22, 2014
  2. George Mpouras

    Re: sys call length limitation

    George Mpouras, Jan 22, 2014, in forum: Perl Misc
    Replies:
    0
    Views:
    60
    George Mpouras
    Jan 22, 2014
  3. Rainer Weikusat

    Re: sys call length limitation

    Rainer Weikusat, Jan 22, 2014, in forum: Perl Misc
    Replies:
    0
    Views:
    62
    Rainer Weikusat
    Jan 22, 2014
  4. Rainer Weikusat

    Re: sys call length limitation

    Rainer Weikusat, Jan 22, 2014, in forum: Perl Misc
    Replies:
    2
    Views:
    64
    Peter J. Holzer
    Jan 23, 2014
  5. gamo
    Replies:
    22
    Views:
    140
    Rainer Weikusat
    Jan 26, 2014
Loading...

Share This Page