« links for 2006-09-20 | Main | links for 2006-09-21 »

How to run a command and save the output, in Perl

Assuming we are in a directory that contains a file called

myfile.

>perl -e "open(FOO,'cat myfile |')|| die 'cat failed'; while (){ print }"

Now I can treat FOO just like I would any other filehandle.