in reply to why can't I

I'm sure that you would have been warned with hints if you would have used use warnings;, as you are using windows-style folder path notation in combination with variable interpolation.

"\srt\$file"

will at least show you something like:

Unrecognized escape \s passed through at test.pl line 12.

Perl will translate unix-style path names to windows style path names when needed and necessary. Just use the correct slashes, and interpolation is no problem:

Furthermore, a readdir () call does not read files like it was from the output of ls or DIR commands, so chomp'ing the names is just an extra attempt to make the file name illegal.

Last, but not least, you open the file whose name is in $file, but the file handle is in $f (which would be more clear if you would use $fh), which should be used for the close ().

use strict; use warnings; my $file; opendir DIR, "/srt" or die "Couldn't open directory, $!"; while ($file = readdir DIR) { open my $fh, "<", "/srt/$file" or die "Open failed : $!"; print "$file\n"; close $fh; } closedir DIR;

Enjoy, Have FUN! H.Merijn