MooseX::Role::WithWorkingDirectory - Syntactic sugar for running a method while in a directory
version 0.02
package MyObject; use Moose; with 'MooseX::Role::WithWorkingDirectory'; sub list_files { system 'ls'; } # later... my $object = MyObject->new; $object->with_wd('/tmp/something')->list_files; # lists files in /tmp/something $object->list_files; # lists files in original CWD
Use this Moose role to add the with_wd method to your classes.
with_wd
Changes the current working directory to $directory, and runs methods in that directory. When those methods return, your application will be back in its original working directory.
$directory
Rob Hoelz <rob@hoelz.ro>
This software is copyright (c) 2011 by Rob Hoelz.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Please report any bugs or feature requests on the bugtracker website http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MooseX-Role-WithWorkingDirec tory
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
To install MooseX::Role::WithWorkingDirectory, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooseX::Role::WithWorkingDirectory
CPAN shell
perl -MCPAN -e shell install MooseX::Role::WithWorkingDirectory
For more information on module installation, please visit the detailed CPAN module installation guide.