I search the Internet for answers to computer technical problems that I encounter. When the Internet does not supply me with an answer, I research one on my own. Then, I document the answer here so others can find it.
Also, for your benefit, this stupid blog name makes a great mnemonic.

2009-10-27

My set complement Perl script.

Currently, my awk-vs-perl knowledge slider is about like this.

awk <--O-------> Perl

I am trying to move it more like this.

awk <-----O---> Perl

To that end, I'll start by translating one of my handy-dandy mini-awk scripts to perl. Have you ever needed to find the elements in one list that were not in another list?

For example, suppose you have a list of all files in a directory. You also have a list of all files in a package, and some of those files in the package list are the ones in the directory list. Now you want to find out what files in the directory are not part of the package.

I was fairly certain that I'd be using 'map' to shorten the code and/or speed things up, but I didn't know the exact syntax. I was going to read the details over on perldoc later. However, I would have never guessed that the _list_ argument of 'map' could be '<>'.