my $dir = 'input_files'; opendir(DIR, $dir) or die "can't opendir $!"; while (defined(my $file = readdir(DIR))) { # do something with "$dirname/$file" print "The directory and file are $dir/$file\n"; open (IN, "< $dir/$file" ) or die ("Can't open input file $!"); while ( < IN > ){ print ; } } closedir(DIR);