Looking at the code, it opens D:/MON/3800-128.html, reads it into memory, creates a copy replacing 'onClick' with 'HREF' and writes this to screen and to the file 0071.html. It then unlinks 0071.html which deletes the file. Not sure what the point is of deleting a file you've just created but hey ho...
Your code is a bit confusing and I think that is probably not helping. Can you describe exactly what you are after? My guess is the following:
Copy 3800-128.html over 0071.html replacing html onClick with HREF.
Replace 3800-128.html with 2800-129.html (no change of html)
Replace 3800-129.html with 2800-130.html (no change of html)
Replace 3800-130.html with 2800-131.html (no change of html)
The following code should do the same as your original but without the memory load of copying the entire input file into memory...
foreach my $q (128..131){
# open the files
# the input file
open( FILE, "<D:/MON/3800-$q.html" );
# the output file
open( MYFILE, '>0071.html' );
# do the replacement and output the results to MYFILE
while (my $line = <FILE>){
$line =~ s/onClick/HREF/isg;
print MYFILE $line;
print $line;
}
print MYFILE '<br/>';
print '<br/><br/><br/>';
# close the files
close(MYFILE);
close(FILE);
unlink("0071.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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.