I want to create a loop to search a file for a pattern, create a hash, then search the file for other occurrances of the key and createlinks using the corresponding value, then loop to the next file andrepeat the process. I have my pattern match working (although I'm notsure it's the best way for it to match) but can't seem to make anythingfurther work. There are approximately 75 files in the directory, allending with .htm.tmp. I can create an array of the files with noproblem, and print the list back to my screen. When I run the code, thetemporary files are created and the permissions are changed. I getnothing on the screen, no error messages, and no print. I am absolutelylost and have no idea how to proceed. Please help!

#!/pw/prod/svr4/perl/bin/perl -w ARGUMENTS: engine_figurelinks.pl xx_manual_vvv # where xx = manual code, vvv = version # use warnings; use diagnostics; use Env qw(SERVER_NAME); use CGI qw(:standard :netscape); use File::Copy; new CGI; ($manualdir_param) = @ARGV; $working_dir = $manualdir_param; $working_dir =~ s/manualdir=//i; $data_area = "/tmp"; $html_dir = "$data_area/$working_dir"; # Loop to locate HTML files, change permissions, and make working temp +orary copies opendir( HTMLSTORIES, "$html_dir") || die "HTML files do not exist: $1 +"; @FigureArray = grep{/\.htm$/} readdir ( HTMLSTORIES ); foreach $figfile (@FigureArray) { copy ("$html_dir/$figfile", "$html_dir/$figfile.tmp") or die " +Can not make temporary copy of file: $1"; chmod 0600, "$html_dir/$figfile"; } closedir HTMLSTORIES; # Loop to do pattern search, create hash and insert links opendir( HTMLSTORIES, "$html_dir") || die "HTML files do not exist: $1 +"; @TmpArray = grep{/\.htm.tmp$/} readdir ( HTMLSTORIES ); foreach $tmpfile (@TmpArray) { my $figures = "$html_dir/$tmpfile" =~ /^(<IMG.*BR>)/ ... /(Figure\s+\W +*)/i; print $figures;} closedir HTMLSTORIES;

In reply to Searching on the Key Field of a Hash 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.