At 02:31 PM 6/27/01 -0400, Noah Sussman wrote:
>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.
Check out HTML::TableExtract:
http://search.cpan.org/search?dist=HTML-TableExtract
>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;
The regex is "double-quotish", so however you'd normally interpolate into
"": either stuff the subroutine results into scalars first (easier), or use
this:
s/@{[standard_search("Call Log")]}@{[standard_search("Billing Log")]}...
*shiver*
--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com