in reply to Re^2: How do I use grep in a script
in thread How do I use grep in a script

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.

Replies are listed 'Best First'.
Re^4: How do I use grep in a script
by Laurent_R (Canon) on Dec 27, 2017 at 21:17 UTC
    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.

      I don't need a lecture. You cited more things irrelevant to this problem: "Good practice", Security, Portability (previously "counterproductive"). My answer was perfectly fine in context.
        "I don't need a lecture..."

        Who knows. But accepting friendly and good advice from some experienced fellow monks isn't a bad thing. And good practice, security and portability always matters.

        «The Crux of the Biscuit is the Apostrophe»

        perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

        I don't need a lecture.
        Alright, sorry about that, I guess I should try to remember not to answer your posts anymore. If I forget, please kindly remind me that you're not open to discussion.