in reply to Re: Where's the leak?
in thread Where's the leak?

A good suggestion, but it's begging for some decoupling.
sub grepfile { my ($rx, $file) = @_; my $ret = system( qw/ perl -0777 /, -e => q{$a = shift; exit (<> !~ /$a/)}, $rx, $file ); return $ret == 0 if $ret != -1; require Carp; Carp::croak "Failed invoking perl for grepfile(): $!"; }
Note how using system(LIST) eliminates any quoting headaches in one easy step.

Makeshifts last the longest.

Replies are listed 'Best First'.
Re: Re^2: Where's the leak?
by BrowserUk (Patriarch) on Dec 24, 2002 at 06:02 UTC

    Yup! Makes it much easier. That covers most of the "many ways to improve it" I hinted at, though I'm surpised you didn't throw in the -n and exit early. Still it is much clearer haw to add that with your version.


    Examine what is said, not who speaks.