my ($extension) = $filename =~ /(\.[^.]*$)/;
fileparse
. use File::Basename; my ($file_without_suffix, $directory, $suffix) = fileparse ('/foo/bar/baz/file.pl', qr/\..[^.]*$/);
use File::Spec; my $full_path = '/absoulte/path/to/a/file'; my $path = '/absoulte/path'; my $relative_path=File::Spec->abs2rel($full_path, $path); print $relative_path; # prints: # to/a/file
use Getopt::Long; GetOptions( 'option' => \my $option, 'v' => \my $verbose, 'help' => \my $help ); if ($option) { ... }