Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl Parse problem

Status
Not open for further replies.

programingnoob

Technical User
Dec 31, 2002
71
CA
Hi,

I have this parse program.

use warnings;
use HTML::TreeBuilder 3;
my $root = HTML::TreeBuilder->new_from_file("browseshop[1].txt");
$flash = $root->find_by_attribute('onclick', "if ( !confirm ('Are you shure') ) { return false; }");

$flash->attr("src");

print $flash->dump;
$root->delete();
#EOF

This program will return 2 matches. The eariler match is a link, and the latter one is an image. I only want the first match, which is the link. How do I do taht?

Thanks
 
Hi,
add a subscript at the end of the function to get the one you want.

$root->find_by_attribute('onclick', "if ( !confirm ('Are you shure') )[0]

----
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top