codewalker has asked for the wisdom of the Perl Monks concerning the following question:
use Cwd 'abs_path'; $dir=abs_path($0); $dir=~s/\\html.pl//g; opendir (DIR, $dir) or die $!; while ($fileName = readdir(DIR)) { if ($fileName=~/\.html/i) { $pathName="$dir\\$fileName"; $pathName=substr($pathName,0,length($pathName)-4); open(DATA, "+<${pathName}html") or die "Couldn't open file file.txt, $ +!"; #open(OUT, ">${pathName}html") or die "Couldn't open file file.txt, $! +"; while(<DATA>) { $line.=$_; } . . . . print OUT $line; } } close (DIR);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: read and write file in directory
by Corion (Patriarch) on Dec 01, 2014 at 12:54 UTC | |
|
Re: read and write file in directory
by jellisii2 (Hermit) on Dec 01, 2014 at 12:44 UTC | |
|
Re: read and write file in directory
by BrowserUk (Patriarch) on Dec 01, 2014 at 12:46 UTC | |
by vinoth.ree (Monsignor) on Dec 01, 2014 at 12:58 UTC | |
by BrowserUk (Patriarch) on Dec 01, 2014 at 13:06 UTC | |
by Corion (Patriarch) on Dec 01, 2014 at 13:14 UTC | |
by BrowserUk (Patriarch) on Dec 01, 2014 at 14:04 UTC | |
|
Re: read and write file in directory
by vinoth.ree (Monsignor) on Dec 01, 2014 at 12:34 UTC | |
|
Re: read and write file in directory
by vinoth.ree (Monsignor) on Dec 01, 2014 at 13:10 UTC | |
|
Re: read and write file in directory
by Anonymous Monk on Dec 01, 2014 at 15:51 UTC |