in reply to read and write file in directory

Here the code I tried in my linux box works fine, it just reads a test.html and prints its content.

use strict; use warnings; use Cwd 'abs_path'; my $dir=abs_path($0); print "$dir\n"; $dir=~s/pl.pl//g; print "after:$dir\n"; opendir (DIR, $dir) or die $!; my $fileName; while ($fileName = readdir(DIR)) { print "$fileName\n"; if ($fileName=~/\.html/i) { my $pathName="$dir/$fileName"; $pathName=substr($pathName,0,length($pathName)-4); open(DATA, "+<${pathName}html") or die "Couldn't open +file file.txt, $!"; while(<DATA>) { print "$_"; } close(DATA); } } closedir(DIR);
You need to use closedir() to close the directory. close() is for file.

All is well