use strict; use warnings; use IPC::Run qw( run ) ; sub process_stdout { my ($fh) = @_; local *_; # Protect caller's $_ while (<$fh>) { chomp; print("[out:$_]\n"); } } sub process_stderr { my ($fh) = @_; local *_; # Protect caller's $_ while (<$fh>) { chomp; print("[err:$_]\n"); } } { # User-defined my $module = "mymodule"; my $OLD = "1.41"; my $NEW = "1.42"; my @cmd = ( 'cvs', 'rlog', "-r${OLD}::${NEW}" '-SN', $module ); my $cvs_in = ''; my $cvs_out = ''; my $cvs_err = ''; run \@cmd, \$cvs_in, \$cvs_out, \$cvs_err or die("Unable to launch CVS\n"); { # Requires Perl 5.8. # In Perl 5.6, use IO::Scalar # or work with $csv_out directly. use 5.008000; open(my $fh, '<', \$cvs_out); process_stdout($fh); } { # Requires Perl 5.8. # In Perl 5.6, use IO::Scalar # or work with $csv_err directly. use 5.008000; open(my $fh, '<', \$cvs_err); process_stderr($fh); } }