in reply to How do I use grep in a script

I think you're looking for backticks (`...` or qx): Quote Like Operators

Replies are listed 'Best First'.
Re^2: How do I use grep in a script
by Laurent_R (Canon) on Dec 26, 2017 at 20:16 UTC
    The OP wants to do it in Perl. I'm afraid it is somewhat counterproductive to suggest shelling out of Perl with backticks or qx//.
      Though there's value in learning how to do it in Perl, I respectfully disagree about the "counterproductive" part. The one-liner being done, just wrap backticks around it, use a split /\n/, and that's that (unless there are other constraints). I wouldn't be surprised if it were also faster, though that depends and might not matter.
        It is usually a recommended good practice not to shell out to the system when you can avoid it. And there are many good reasons for that, security and portability just to name a few. I think it should be avoided especially when the commands you want to run exists in core Perl.

        See, for example, Calling External Commands More Safely and The problem of "the" default shell.