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() { print "$_"; } close(DATA); } } closedir(DIR);