#!/usr/bin/perl ###################################################################### # squirrel -- Mike Schilli, 2002 (m@perlmeister.com) ###################################################################### use File::Spec; use File::Copy; use Pod::Usage; our $CVSVERSION = '$Revision: 1.4 $'; my($module) = $ARGV[0]; pod2usage() unless defined $module; (my $module_path = $module) =~ s#::#/#g; $module_path .= ".pm"; for my $path (@INC) { my $full = File::Spec->catfile($path, $module_path); if(-f $full) { print "Squirrelling away $module\n"; move($full, "$full.squirrelled") or die "Cannot move $full"; exit 0; } if(-f "$full.squirrelled") { print "Resurrecting $module\n"; move("$full.squirrelled", $full) or die "Cannot move $full.squirrelled"; exit 0; } } die "Can't find $module_path anywhere in @INC\n"; __END__ =head1 NAME squirrel - squirrel away and resurrect perl modules for testing =head1 DOWNLOAD _SRC_HERE_ =head1 SYNOPSIS squirrel Foo::Bar::Baz =head1 DESCRIPTION Ever wondered what happens to a script of yours if a certain module is missing from your perl installation? C makes it easy to squirrel away installed modules momentarily and resurrect them later on. C will take a module name like C (without the *.pm suffix) as an argument, walk the C<@INC> path to search for it and move C<.../Foo/Bar/Baz.pm> to C<.../Foo/Bar/Baz.pm.squirrelled>. Called again with the same module name it will find C<.../Foo/Bar/Baz.pm.squirrelled> and resurrect it to be C<.../Foo/Bar/Baz.pm>. =head1 EXAMPLES $ squirrel LWP::UserAgent Squirrelling away LWP::UserAgent $ squirrel LWP::UserAgent Resurrecting LWP::UserAgent =head1 LEGALESE Copyright 2002 by Mike Schilli, all rights reserved. This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =head1 AUTHOR 2002, Mike Schilli