in reply to search/grep perl/*nix

I was going to have a much more detailed response, but ++1nickt and ++haukex beat me to the "how to do it inside perl".

In other news, your first qw{cut -d"," -f17 $file | sort | uniq > $tmpfile} does not do what you think. Specifically, the qw form splits the text contained within on the spaces, making a list of 'cut', '-d","', ... in void context; use warnings would have told you

Possible attempt to separate words with commas at 1204245.pl line 13. Useless use of a constant ("cut") in void context at 1204245.pl line 1 +3. Useless use of a constant ("-d\",\"") in void context at 1204245.pl li +ne 13. ...
and then it would have died with a message like
1204245-data.tmp: No such file or directory at 1204245.pl line 15.
I am assuming you actually ran qx{cut -d"," -f17 $file | sort | uniq > $tmpfile}, which would have done what you claimed, but would have been better implemented with system, because qx takes the output and puts it in a string, which you were using in void context; system just executes the command.

That said, follow 1nickt and haukex advice for how to do it in perl, without invoking external commands, much more efficiently..

(argh: ++hippo even beat me to pointing out this error, plus the missing semicolon which I forgot to mention; I'm only still posting because of my sunk cost. *sigh*)

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

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