#!/usr/bin/perl -w use strict; use File::Basename; use Cwd; print "dollar 0 is $0\n"; print basename($0), "\n"; print "current working directory is: ",cwd(),"\n"; __END__ On Windows, you get: dollar 0 is C:\TEMP\exename.pl exename.pl current working directory is: C:/TEMP On Linux, you get: dollar 0 is ./exename.pl exename.pl current working directory is: /home/xxx/yy