I'm new to Perl and have been put in the position of being the only Perl programmer in a huge Perl shop, maintaining and writing lots of Perl code they need yesterday. This one has me stumped.

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 #------------------------------------------------------

In reply to Making tmp copies of files by xdbd063

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.