IPC::Run3::Simple - Simple utility module to make the easy to use IPC::Run3 even more easy to use.
This document describes v0.011 of IPC::Run3::Simple - released April 23, 2012 as part of IPC-Run3-Simple.
use IPC::Run3::Simple; # Dead simple, ignoring system error and getting rid of the final newline in # the output. my ( $out, $err ) = run3( [qw( ls -AGlh )] ); # syserr and timing is ignored die $err if $err; # Manipulate $out however you want. # Dump file listing into array, then chomp the array, ignoring any errors. my $args = { 'cmd' => [qw( ls -AGlh )], 'stdout' => \my @files, }; run3( $args ); for my $file ( @files ) { print "filename: $file\n" }
If a false value is passed, run3 will not chomp any error if it's stored in a scalar or array ref. Default is to chomp any error.
If a false value is passed, run3 will not chomp the result if it's stored in a scalar or array ref. Default is to chomp any result.
If a false value is passed, run3 will return instead of croaking on error. Default is to return instead of croaking.
Set the default stdin to be used. Default is 'undef' (inherits the parent's STDIN filehandle). See L<IPC::Run3> documentation for other options.
Set the default stdout to be used. Default is a scalar reference. See L<IPC::Run3> documentation for other options.
Set the default stderr to be used. Default is a scalar reference. See L<IPC::Run3> documentation for other options.
Turn on or off teeing of system call. If L<Capture::Tiny> is not installed this will be ignored.
This method is exported into the calling namespace.
Expects either a reference to an array or a reference to a hash.
If a reference to an array is passed it is assumed to be a list of the command and option(s) to be run. A list containing the results, errors, exit code and execution time (in that order) will be returned. See SYNOPSIS for an example.
If a reference to a hash is passed in, the following information is expected:
See IPC::Run3 documentation for possible values for each of these keys. 'cmd' Required 'stdin' Optional 'stdout' Optional 'stderr' Optional 'options' Optional
Note: If any of stdin, stdout or stderr are not passed in the hash 'undef' will be used in their place.
In addition, the following variables can be set, either in the hash passed in or globally via $IPC::Run3::Simple::VARIABLE.
CROAK_ON_ERR If true, run3 will 'croak $stderr' instead of returning if $stderr contains anything. Default is to return instead of croaking. CHOMP_OUT If true, run3 will 'chomp $$stdout' if stdout is a scalar reference or 'chomp @$stdout' if stdout is an array reference. Otherwise, it has no effect. If false, nothing will be done to the output of the call. Default is true. CHOMP_ERR If true, run3 will 'chomp $$stderr' if stderr is a scalar reference or 'chomp @$stderr' if stderr is an array reference. Otherwise, it has no effect. If false, nothing will be done to the error output of the call. Default is true. TEE_SYSTEMCALL This depends on the L<Capture::Tiny> package. If it is not available this option will be silently ignored. If true, run3 will wrap the system call in the Capture::Tiny::tee function which will dump the output to STDERR and STDOUT as usual while still returning the output to the calling function.
See perlmodinstall for information and options on installing Perl modules.
Alan Young <harleypig@gmail.com>
This software is copyright (c) 2012 by Alan Young.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
To install IPC::Run3::Simple, copy and paste the appropriate command in to your terminal.
cpanm
cpanm IPC::Run3::Simple
CPAN shell
perl -MCPAN -e shell install IPC::Run3::Simple
For more information on module installation, please visit the detailed CPAN module installation guide.