Mojo::File::Role::Extension - Access Mojo::File filename extensions
$file = Mojo::File->new('/some/path.txt')->with_roles('+Extension'); # .txt $file->extension; # /some/path.csv $file->switch_extension('.csv');
Add file extension access and modifying behaviour to Mojo::File.
The Mojo::File::Role::Extension role adds the following methods to a Mojo::File once composed.
# .txt $file->extension;
Readonly access to the file extension of the file or directory.
# ['.tar', '.gz'] $file->extension_parts;
Readonly access to the file extension(s) of the file or directory. The parts are returned as a Mojo::Collection of strings.
# path $file->moniker;
Readonly access to the short name of the file, i.e. prior to the "extension".
# /some/path.csv $file->switch_extension('.csv');
Change the extension of the Mojo::File, retaining the rest of the path and return a new Mojo::File object.
This library is free software. You can redistribute it and/or modify it under the same terms as Perl itself.
Roy Storey - <kiwiroy@cpan.org>
To install Mojo::File::Role::Extension, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojo::File::Role::Extension
CPAN shell
perl -MCPAN -e shell install Mojo::File::Role::Extension
For more information on module installation, please visit the detailed CPAN module installation guide.