NAME
IPC::Open3::Callback::CommandRunner - A utility class that wraps IPC::Open3::Callback with available output buffers and an option to die on failure instead of returning exit code.
VERSION
version 1.16
SYNOPSIS
use IPC::Open3::Callback::CommandRunner;
my $command_runner = IPC::Open3::Callback::CommandRunner->new();
my $exit_code = $command_runner->run( 'echo Hello, World!' );
eval {
$command_runner->run_or_die( $command_that_might_die );
};
if ( $@ ) {
print( "command died: $@\n" );
}
DESCRIPTION
Adds more convenience to IPC::Open3::Callback by buffering output and error if needed and dieing on failure if wanted.
CONSTRUCTORS
new()
The constructor creates a new CommandRunner.
ATTRIBUTES
get_err_buffer()
Returns the contents of the err_buffer from the last call to run or run_or_die.
get_out_buffer()
Returns the contents of the err_buffer from the last call to run or run_or_die.
METHODS
run( $command, $arg1, ..., $argN, \%options )
Will run the specified command with the supplied arguments by passing them on to run_command. Arguments can be embedded in the command string and are thus optional.
If the last argument to this method is a hashref (ref(@_[-1]) eq 'HASH'
), then it is treated as an options hash. The supported allowed options are the same as run_command plus:
- out_buffer
-
If true, a callback will be generated for
STDOUT
that buffers all data and can be accessed via out_buffer() - err_buffer
-
If true, a callback will be generated for
STDERR
that buffers all data and can be accessed via err_buffer()
Returns the exit code from the command.
run_or_die( $command, $arg1, ..., $argN, \%options )
The same as run exept that it will die
on a non-zero exit code instead of returning the exit code. If the out_buffer
option was specified, the output from the command will be returned.
AUTHORS
Lucas Theisen <lucastheisen@pastdev.com>
Alceu Rodrigues de Freitas Junior <arfreitas@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2013 by Lucas Theisen.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
SEE ALSO
Please see those modules/websites for more information related to this module.