# change_directory.pl use warnings; use strict; use Cwd; my $current_dir = getcwd(); #list the Timepoint directories my @TP_dir = glob("T*"); for my $dir (@TP_dir) { my $fulldir = "$current_dir/$dir"; if (-d $fulldir) { chdir($fulldir) or die "error: chdir '$fulldir': $!"; my $currdir = getcwd(); print "cd worked: currdir is now '$currdir'\n"; } else { print "oops: '$fulldir' is not a dir\n"; } }