X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FIO%2FPipeline.pm;h=165dadbecc864890bbf49a1d3a3b08a915ec1c2b;hb=eef5e44f3ea35cc476b6fdbbd0299b4cbdcae3fb;hp=48aa2388791ea6319536152ebce3891574b643d5;hpb=fe528e03b10e25bb7a70c37b5e925425fb554e4f;p=p5sagit%2FIO-Pipeline.git diff --git a/lib/IO/Pipeline.pm b/lib/IO/Pipeline.pm index 48aa238..165dadb 100644 --- a/lib/IO/Pipeline.pm +++ b/lib/IO/Pipeline.pm @@ -11,7 +11,7 @@ our @ISA = qw(Exporter); our @EXPORT = qw(pmap pgrep psink); -our $VERSION = '0.009001'; # 0.9.1 +our $VERSION = '0.009002'; # 0.9.2 $VERSION = eval $VERSION; @@ -191,7 +191,7 @@ the pipe to the output until the input filehandle is exhausted. Non-completed pipeline objects are completely re-usable though - so you can (and are expected to) do things like: - my $combined_to_stoud = $combined | \*STDOUT; + my $combined_to_stdout = $combined | \*STDOUT; foreach my $file (@files_to_process) { @@ -327,19 +327,44 @@ a variable so that we can examine the results: | psink { $out .= $_ }; +=head1 COOL EXAMPLES + +=head2 tail colorize + +The following example simply colors the lines that match a given regular +expression. It watches C, so the typical usage would be + + tail -f foo | perl tail-color.pl + +If you are on a Windows system take a look at L to +make the colors work and L for a pure-Perl implementation of tail. + + use IO::Pipeline; + use Term::ANSIColor; + + my $reset = color 'reset'; + + sub colorize { + my ($regex, $color) = @_; + pmap { return colored([$color], $_) if $_ =~ $regex; $_ } + } + +\*STDIN | + colorize(qr/^INFO: .*$/, 'blue') | + colorize(qr/^HELP: .*$/, 'bright_red on_magenta') | +\*STDOUT; + =head1 AUTHOR Matt S. Trout (mst) -=head2 CONTRIBUTORS +=head1 CONTRIBUTORS -None as yet, though I'm sure that'll change as soon as people spot the -giant gaping holes that inevitably exist in any software only used by -the author so far. +frew: Arthr Axel "fREW" Schmidt =head1 COPYRIGHT -Copyright (c) 2010 the App::FatPacker L and L +Copyright (c) 2010 the IO::Pipeline L and L as listed above. =head1 LICENSE