in reply to Filehandles and Input and Output Filters
Here's a trivial example. Suppose you have a program that generates some output, but you'd like the output sorted. You can do it like so:
use strict; use warnings; open my $F1, '| sort >t' or die; while (<DATA>) { print $F1 $_; } __DATA__ the quick red fox jumped over the lazy brown dog
This trivial program just writes a few words, and then uses the sort program to sort the output using the sort program as a filter. When you run it, you get this:
$ perl foo.pl $ cat t brown dog fox jumped lazy over quick red the the
...roboticus
When your only tool is a hammer, all problems look like your thumb.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Filehandles and Input and Output Filters
by devarishi (Initiate) on Nov 03, 2011 at 13:35 UTC | |
by roboticus (Chancellor) on Nov 04, 2011 at 00:51 UTC |