xdbd063 has asked for the wisdom of the Perl Monks concerning the following question:
As the result of about 20 other perl scripts there are about 75 files in a directory. I match all the files ending in .htm into a hash, that works fine. I can print those to the screen just fine, but if I try and make a copy of each of the files in the hash I get into trouble, I can't make it work. I'm in a lot of trouble here and would appreciate any help at all I can get.
After I make the tmp files, my plan is to do a pattern search in each tmp file for a specific group of lines, put those lines into a hash, search the file for the key and put a link to the value that matches the key, copy the tmp file over the original file and remove the tmp file.
1 #!/pw/prod/svr4/perl/bin/perl -w 27 # ARGUMENTS: engine_figurelinks.pl xx_manual_vvv 28 # where xx = manual code, vvv = version 29 # 30 # MODIFICATIONS: 31 # 32 #------------------------------------------------------ 33 34 use warnings; 35 use diagnostics; 36 use Env qw(SERVER_NAME); 37 use CGI qw(:standard :netscape); 38 use File::Copy; 39 new CGI; 40 #------------------------------------------------------ 41 42 ($manualdir_param) = @ARGV; 43 $working_dir = $manualdir_param; 44 $working_dir =~ s/manualdir=//i; 45 46 $data_area = "/tmp"; 47 $html_dir = "$data_area/$working_dir"; 48 49 #------------------------------------------------------ 50 51 # Loop to locate HTML files and make working tmp copies 52 53 opendir( HTMLSTORIES, "$html_dir") || die "HTML files do not exis +t: $1"; 54 @FigureArray = grep{/\.htm$/} readdir ( HTMLSTORIES ); 55 foreach $figfile (@FigureArray) { 56 copy ($figfile, "$1.tmp") or die "Can not make temporary +copy of file: $1"; 57 } 58 59 closedir HTMLSTORIES; 60 #------------------------------------------------------
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Making tmp copies of files
by alienhuman (Pilgrim) on Feb 21, 2006 at 17:59 UTC | |
by xdbd063 (Friar) on Feb 21, 2006 at 18:53 UTC | |
by shotgunefx (Parson) on Feb 21, 2006 at 19:07 UTC | |
by xdbd063 (Friar) on Feb 21, 2006 at 19:07 UTC | |
by alienhuman (Pilgrim) on Feb 21, 2006 at 19:24 UTC |