String::FilenameStatic - Static functions to manipulate a filename and path.
# imports all functions use String::FilenameStatic ':all'; # imports only two functions use String::FilenameStatic qw(get_path get_file);
This class provides static functions which can be imported to the namespace of the current class.
Exporter
my $string = get_file($string);
Extracts the whole filename without the path
print get_file('/etc/webserver/httpd.conf'); # writes: 'httpd.conf'
my $string = get_file_extension($string);
Extracts the extension of a filename
print get_file_extension('/etc/webserver/httpd.conf'); # writes: 'conf'
my $string = get_filename($string);
print get_filename('/etc/webserver/httpd.conf'); # writes: 'httpd'
Yes, it sounds very similar to get_file(), but I had no better idea to describe it without writing get_file_without_extension.
my $string = get_path($string);
Extracts the path of a filename.
print get_path('/etc/webserver/httpd.conf'); # writes: '/etc/webserver'
my $string = remove_trailing_slash($string);
Returns the path without a slash on the end. You can use it more than once, without doing something wrong to the same string.
Andreas Hernitscheck ahernit(AT)cpan.org
You can redistribute it and/or modify it under the conditions of LGPL.
To install String::FilenameStatic, copy and paste the appropriate command in to your terminal.
cpanm
cpanm String::FilenameStatic
CPAN shell
perl -MCPAN -e shell install String::FilenameStatic
For more information on module installation, please visit the detailed CPAN module installation guide.