use Path::Class; my $file = './hello.txt'; my $path = Path::Class::File->new($file)->absolute; print "the file ", $path->basename", "is in the ", $path->dir, "directory\n"; # or if dealing with file specifications of a different platform... $file = "c:\\Documents and Settings\\you\\..\\me\\hello.txt"; $path = Path::Class::File->new_foreign('Win32', $file)->absolute;