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 '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.04 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::Extra  Shell => 'echo';
   # = use IPC::Run3::Shell 'echo';                # import "echo"
 use Shell::Tools::Extra  Shell => [ qw/cat who/ ];
   # = use IPC::Run3::Shell qw/cat who/;           # import "cat" and "who"
 use Shell::Tools::Extra  Shell => [ [ d => '/bin/date' ] ];
   # = use IPC::Run3::Shell [ d => '/bin/date' ];  # alias "d" to "date"

The word Shell followed by either a string or an array reference may be placed anywhere in the import list, which will cause the IPC::Run3::Shell module to be loaded with those arguments. 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 = rule->file->name('*.pm')->in(@INC);
 my $rule = rule->dir->name(qr/te?mp/i)->start($ENV{HOME});
 while ( defined( my $tmpdir = $rule->match ) ) {

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