fadingjava has asked for the wisdom of the Perl Monks concerning the following question:
#!c:\perl\perl.exe # open directory and get all filenames in one array my $path = "c:/perl/dvd_files/"; opendir(LOCAT, $path) or die "Couldn't open folder, $!\n"; my @folder = grep !/^\.\.?$/, readdir(LOCAT); closedir (LOCAT); # foreach file open it and strip pattern and rewrite a text file foreach my $file (@folder) { my $full_path = $path.$file; #print "$full_path\n"; open SWORD, "< $full_path" or die "file could not be opened:$!"; print "here\n"; $full_path =~ s/sub/txt/gi; $full_path =~ s/srt/txt/gi; $full_path =~ s/txt/txt/gi; open WRITE, "> $full_path" or die "file could not be written:$!"; while (<SWORD>){ print "$_\n"; $_=~ s/[\{0-9\}\{0-9\}]//g; print "here"; print WRITE $_; } close (SWORD); close (WRITE); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: reading text from afile
by ysth (Canon) on Sep 28, 2004 at 06:58 UTC | |
by fadingjava (Acolyte) on Sep 28, 2004 at 07:57 UTC | |
|
Re: reading text from afile
by Zaxo (Archbishop) on Sep 28, 2004 at 07:49 UTC | |
by fadingjava (Acolyte) on Sep 28, 2004 at 08:24 UTC | |
|
Re: reading text from afile
by bobf (Monsignor) on Sep 28, 2004 at 08:07 UTC | |
|
Re: reading text from afile
by thor (Priest) on Sep 28, 2004 at 11:55 UTC |