in reply to search/grep perl/*nix

The first piece of code runs a shell grep and writes the output into a file.

Actually, it doesn't. Partly this is because it doesn't compile due to the missing semi-colon at the end of the first line but even if you fix that you should see that it doesn't shell out at all. You probably meant to use the qx operator instead of qw but that would make no sense because you are using it in void context.

With these mistakes it is hard to know what code you are really running (it certainly can't be what you've posted). This makes it very difficult to provide any insight (as discussed in How do I post a question effectively?). Instead, here's a free tip. Never do this:

$ foo | sort | uniq

if you are concerned about optimisation. sort has a -u flag which is much more efficient that firing up a separate uniq to de-duplicate the dataset.

Replies are listed 'Best First'.
Re^2: search/grep perl/*nix
by Gtforce (Sexton) on Nov 25, 2017 at 17:25 UTC

    Both typos corrected on the post (the original code that I have is ok), apologies.

      G'day Gtforce,

      "Both typos corrected on the post (the original code that I have is ok), apologies."

      It's fine to make corrections to your posts, but you also need to indicate what's changed at the point where the change occurred (e.g. you've said you made a correction here, several screenfuls away from the correction, but there's no indication of that in the OP itself). When I first read this thread, I couldn't initially understand why people were saying use 'qx' instead of 'qw': your OP had no apparent 'qw'. See "How do I change/delete my post?" for a more complete discussion.

      Because it's directly related, and to save writing a separate reply, in "Re^2: search/grep perl/*nix" you wrote:

      "It is qx and I did have the ending semicolon (daft of me to make these typos on the post), apologies."

      The easiest way to avoid this, and what I do, is to just copy and paste your code directly into your post. This is a lot less work than actually typing your code and, because there's no typing involved, you won't make typos.

      — Ken