Hello, I am wondering how i can use a subroutine as the search string for
s//.
Specifically, I am trying to search through a large number of HTML documents
which contain an arrangement of similar (not identical!) table cells. All I
want to do is rearange the order of the cells, but it seems innefecient to
do this:
s{
(<td(?!Call Log).*Call Log.*?</td>\s*)
(<td(?!Billing Log).*Billing Log.*?</td>\s*)
(<td(?!My Account).*My Account.*?</td>\s*)
(<td(?!Help).*Help.*?</td>\s*)
(<td(?!Calling Plans).*Calling Plans.*?</td>\s*)
}{
$3 $1 $2 $5 $4
}gx;
when each of the parenthesized groupings above contains an almost identical
search string : (<td(?!STRING).*STRING.*?</td>\s*), and it seems like I
should be able to do something like this:
s{
standard_search(Call Log)
standard_search(Billing Log)
standard_search(My Account)
standard_search(Help)
standard_search(Calling Plans)
}{
$3 $1 $2 $5 $4
}gx;
sub standard_search {
my $look_for = shift;
my $regex_is = "(
<td
(?!$look_for)
.*
$look_for
.*?
</td>
\s*)"
return $regex_is;
}
Does anyone have ideas or code on how I could make this work?
Thanks so much!
--
Noah Sussman
Senior Web Developer
Deltathree, The IP Communications Network
75 Broad St, 31st Floor
New York, NY 10004
tel 212-500-4845
fax 212-500-4888
[EMAIL PROTECTED]
www.deltathree.com
"A foolish consistency is the hobgoblin of little minds."
-- Emerson