Re: how do I grep and have the matched single line in perl variable



On Sep 23, Manish Sapariya said:

I want to have pure perl equivalent of following:

my $out = `my_utility | grep manish`;

which will give me the lines containing manish in the output
of my_utility in variable $out.

You'd use the aptly-named grep() function in Perl to get only those elements returned by `my_utility` that have 'manish' in them:


  my @wanted = grep /manish/, `my_utility`;

--
Jeff "japhy" Pinyan        %  How can we ever be the sold short or
RPI Acacia Brother #734    %  the cheated, we who for every service
http://www.perlmonks.org/  %  have long ago been overpaid?
http://princeton.pm.org/   %    -- Meister Eckhart
.