xdbd063 has asked for the wisdom of the Perl Monks concerning the following question:
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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Searching on the Key Field of a Hash
by GrandFather (Saint) on Feb 23, 2006 at 20:54 UTC | |
|
Re: Searching on the Key Field of a Hash
by dynamo (Chaplain) on Feb 23, 2006 at 22:47 UTC | |
by xdbd063 (Friar) on Feb 24, 2006 at 15:23 UTC | |
by xdbd063 (Friar) on Feb 24, 2006 at 15:30 UTC |