in reply to Re^2: Reading DIR content and printing it
in thread Reading DIR content and printing it

In addition to checking for errors, $f has a newline at its end. Again, if you had used warnings, Perl would have told you so:

Unsuccessful open on filename containing newline at -e line 1.

Also, when printing out values, always put delimiters around them so you see whitespace:

print "[$f]\n";