#!/usr/bin/perl use Cwd; open(FILE, ") { $hash{$.} = $_; } close(FILE); foreach (keys %hash) { my ($num) = $hash{$_} =~ m/(.*)?\..*/; if (-d $num) { # ah! the folder exists! print("The folder $num exists! so make your killerapp do the work!!!\n"); chdir $num or die("Cannot change to directory\n"); print "Current folder = " . getcwd() . "\n"; #Now do your stuff in this folder here! chdir ".." or die("Cannot go back...\n"); print "Current folder = " . getcwd() . "\n"; } }