Perl Monk, Perl Meditation | |
PerlMonks |
Saving a Pattern Match from Subroutineby shoness (Friar) |
on Jul 23, 2007 at 13:18 UTC ( [id://628232]=perlquestion: print w/replies, xml ) | Need Help?? |
shoness has asked for the wisdom of the Perl Monks concerning the following question:
Hi, You can probably help me even if you don't know details of HTML::TreeBuilder or of my application. My question is more general Perl, but framed in my own world. As usual, I can solve this via a very brute force method, but "there has to be a better way". I'm using HTML::TreeBuilder to grab the filename of an anchor that is an immediate child of a known tag. The structures look like: I want to return a list that contains all the files from key sections like this. For example, the section above should simply "push(@list, "file23.html");" The snippet below will find the span containing the anchor. I really don't care about that. I just want to push "$1" from the qr// search in the subroutine call into the list. My brute force method is to find all the anchors that fit my pattern and look at their immediate parent to see if they have the "span" tag that interests me, pulling the filename out if it does. Oh, and the subroutine itself must continue to return a "1" or the look_down() will stop at that point and I won't get all the files. Thanks for your help!
Back to
Seekers of Perl Wisdom
|
|