One liners make me nervous, so here is a way to get at all the html files in a directory, works on windows with ActiveState, maybe works on unix as well... hope this helps!
#use strict;
#use warnings;
my ($dirname, $file, %words);
opendir(DIR, ".") or die "can't opendir $dirname: $!";
while (defined($file = readdir(DIR))) {
if ($file =~ /\.html?/) {
open my $F, $file or die "Could not open $file\n";
while (<$F>) {
#do stuff
s/
(?<= # Look back-group
weak # Match the word weak
<INPUT TYPE=radio NAME= # tag
( # Capuring group: $1 / \1
\w{2}\d\w{2} #
) # End-capture
VALUE=\d> # tag
(?: # Non capturing group
<INPUT TYPE=radio NAME= # tag
\1 # It's possible that this should be $
+1, as I said, the code is untested.
VALUE=\d>
){6} # There are 7 input tags, one already
+ matches, so 6 to go.
) # End look-back
(?= # Look-ahead-group
strong
) # End look-ahead
/
the text you want to insert
/ixg;
}
close $F;
}
}
closedir(DIR);
UPDATE: Integrated holli's fix and animator's regex code from below. (untested!)
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.