Capture-Tiny-Extended
view release on metacpan or search on metacpan
lib/Capture/Tiny/Extended.pm view on Meta::CPAN
sub {
# lockfile and other processing here along with debug output
return system( 'long_running_program' );
},
{
stdout => 'out.log',
stderr => 'err.log',
}
);
send_mail( $err ) if $res;
=head2 capture_files
Since using hashes in that way breaks a bit of the syntax magic of the capture
functions (or makes them harder to read), there exists a sugar function to take
the file arguments and pass it on to the capture functions:
use Capture::Tiny::Extended qw( capture capture_files );
my ( $out, $err, $res ) = capture {
# lockfile and other processing here along with debug output
return system( 'long_running_program' );
}
capture_files {
stdout => 'out.log',
stderr => 'err.log',
};
send_mail( $err ) if $res;
=head2 Capture File Mode Options
For purposes of avoiding data loss, the default behavior is to append to the
specified files. The key 'new_files' can be set to a true value on the extra
file hash parameter to instruct Capture::Tiny::Extended to attempt to make
files. It will die however if the specified files already exist.
use Capture::Tiny::Extended 'capture';
my $out = capture_merged(
sub { system( 'ls' ) },
{ stdout => 'out.log', new_files => 1 }
);
If existing files should always be overwritten, no matter what, the key
'clobber' can be set instead:
use Capture::Tiny::Extended 'capture';
my $out = capture_merged(
sub { system( 'ls' ) },
{ stdout => 'out.log', clobber => 1 }
);
=head1 WHY A FORK?
The realtime teeing feature was very important for one of my current projects
and i needed it on CPAN to be able to easily distribute it to many systems.
I had provided a patch for the return value capturing on Github to David Golden
a long while ago, but due to being busy with real life, family and more
important projects than this he was not able to find time to proof and integrate
it and in the foreseeable future won't be able to either. At the same time i
lack the Perl file handle, descriptor and layer chops to take full
responsibility for Capture::Tiny itself. Usually i would have just written a
subclass of the original, but since Capture::Tiny is written in functional style
this was not possible.
As such a fork seemed to be the best option to get these features out there. I'd
be more than happy to see them integrated into C::T someday and will keep my git
repository in such a state as to make this as easy as possible. (Lots of
rebasing.)
=head1 ACKNOWLEDGEMENTS
Capture::Tiny is an invaluable tool that uses practically indecent amounts of
creativity to solve decidedly nontrivial problems and circumvents many cliffs
the ordinary coder (and most certainly me) would inevitably crash against.
Many thanks to David Golden for taking the time and braving all those traps of
insanity to create Capture::Tiny.
=for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders
=head1 SUPPORT
=head2 Bugs / Feature Requests
Please report any bugs or feature requests by email to C<bug-capture-tiny-extended at rt.cpan.org>, or through
the web interface at L<http://rt.cpan.org/Public/Dist/Display.html?Name=Capture-Tiny-Extended>. You will be automatically notified of any
progress on the request by the system.
=head2 Source Code
This is open source software. The code repository is available for
public review and contribution under the terms of the license.
L<https://github.com/wchristian/capture-tiny>
git clone https://github.com/wchristian/capture-tiny
=head1 AUTHORS
=over 4
=item *
Christian Walde <mithaldu@yahoo.de>
=item *
David Golden <dagolden@cpan.org>
=back
=head1 COPYRIGHT AND LICENSE
This software is Copyright (c) 2009 by David Golden.
This is free software, licensed under:
( run in 2.351 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )