vcherubini
Programmer
Hello:
I have a question about a complicated regex that I can not seem to get working.
Here is the code:
[tt]
#!usr/bin/perl
open(HTML, "link.html" || die ("can't open file: $!"
@links = <HTML>;
close(FILE);
@links = m/<A[^>]+?HREF\s*=\s*["´]?([^´" >]+?)[ ´"]?>/sig;
foreach $link (@links) {
print "$link\n";
}
[/tt]
And here is the HTML file that it reads from:
[tt]
<html>
<head>
<title>this is some links</title>
</head>
<body>
<A HREF="link1.html">blah</A>
<A HREF="link1.html">blah2</A>
<A HREF="link1.html">blah3</A>
<A HREF="link1.html">blah4</A>
<A HREF="link1.html">blah5</A>
</body>
</html>
[/tt]
The regex says that it should parse out all of the A HREF's in the HTML, but, whenever I run it, I dont get anything, just a blank screen.
Any help on how this works is appreciated.
Thank you.
-Vic [sig]<p>vic cherubini<br><a href=mailto:malice365@hotmail.com>malice365@hotmail.com</a><br><a href= software</a><br>====<br>
Knows: Perl, HTML, JavScript, C/C++, PHP, Flash, Director<br>
Wants to Know: Java, Cold Fusion, Tcl/TK<br>
====[/sig]
I have a question about a complicated regex that I can not seem to get working.
Here is the code:
[tt]
#!usr/bin/perl
open(HTML, "link.html" || die ("can't open file: $!"
@links = <HTML>;
close(FILE);
@links = m/<A[^>]+?HREF\s*=\s*["´]?([^´" >]+?)[ ´"]?>/sig;
foreach $link (@links) {
print "$link\n";
}
[/tt]
And here is the HTML file that it reads from:
[tt]
<html>
<head>
<title>this is some links</title>
</head>
<body>
<A HREF="link1.html">blah</A>
<A HREF="link1.html">blah2</A>
<A HREF="link1.html">blah3</A>
<A HREF="link1.html">blah4</A>
<A HREF="link1.html">blah5</A>
</body>
</html>
[/tt]
The regex says that it should parse out all of the A HREF's in the HTML, but, whenever I run it, I dont get anything, just a blank screen.
Any help on how this works is appreciated.
Thank you.
-Vic [sig]<p>vic cherubini<br><a href=mailto:malice365@hotmail.com>malice365@hotmail.com</a><br><a href= software</a><br>====<br>
Knows: Perl, HTML, JavScript, C/C++, PHP, Flash, Director<br>
Wants to Know: Java, Cold Fusion, Tcl/TK<br>
====[/sig]