Shell::Tools::Extra - Perl extension to reduce boilerplate in Perl shell scripts (Extra modules)


 use Shell::Tools::Extra;    # is the same as the following:
 use Shell::Tools; # turns on warnings and strict and exports many funcs
 use Try::Tiny qw/try catch finally/;
 use Path::Class qw/dir file/;
 use File::pushd 'pushd';
 use File::Find::Rule ();
 # and
 use Shell::Tools::Extra  Shell => [ IPC_RUN3_SHELL_ARGS ];
 # is the same as
 use IPC::Run3::Shell IPC_RUN3_SHELL_ARGS;


This module exports a collection of functions from selected Perl modules from CPAN, in addition to those from Shell::Tools.


This document describes version 0.02 of Shell::Tools::Extra.


This module exports the following modules and functions.

Like Shell::Tools, each module has an Exporter tag that is the same name as the module.


 use Shell::Tools  Shell => [ qw/echo cat/ ];
 use Shell::Tools  Shell => 'who';

The argument(s) will be passed through as the arguments to IPC::Run3::Shell's import. Note that Shell must be followed by exactly one argument, either a single scalar or an arrayref.

This module is optional: If no Shell arguments are present in use, this module will not be loaded and it does not need to be installed.


 try { die "foo" }
 catch { warn "caught error: $_\n" }  # not $@
 finally { print "finally" };


 my $dir      = dir('foo', 'bar');        # Path::Class::Dir object
 my $file     = file('bob', 'file.txt');  # Path::Class::File object
 # interfaces to File::Spec's tempdir and tempfile
 my $tempdir  = Path::Class::tempdir(CLEANUP=>1);   # isa Path::Class::Dir
 my ($fh,$fn) = $tempdir->tempfile(UNLINK=>1);      # $fn is NOT an object

(Note that Path::Class may not work properly with Perl before v5.8.0.)


     my $dir = pushd('/tmp');
     # working directory changed to /tmp
 # working directory has reverted to previous


 my @files = File::Find::Rule->file->name('*.pm')->in(@INC);

Author, Copyright, and License

Copyright (c) 2014 Hauke Daempfling (

This library is free software; you can redistribute it and/or modify it under the same terms as Perl 5 itself.

For more information see the Perl Artistic License, which should have been distributed with your copy of Perl. Try the command "perldoc perlartistic" or see