use strict; use warnings; use File::Basename; use Cwd; my $file_name = './hello.world'; # Insert your file-name gathering logic here # Place the results in $file_name. my ($base_name, $path, $suffix) = fileparse($file_name); if ($path =~ /\./) { $path = cwd(); }