Change dir with chdir
#! /usr/local/bin/perl use Cwd; $dir = cwd; print "dir=> $dir\n"; chdir ('D:\\mydir'); $dir = cwd;