Try
$file="C:\\Program Files\\Apache Group\\Apache\\htdocs\\linux.htm";
open (IN, "$file") or die "Can't open $file: $!"; # ALWAYS CHECK OPENS
while (<IN>) {
/<a href=\"(.+)\">.+<\/a>/; # This will act on the value of $_ which you
are setting with while (<IN>)
print "$1<BR>"; # You can combine this into one line
}
close IN;
That may work. I'm not sure what was causing it to print the line twice. N.B
using regexs to play with HTML can bite you. Be warned. There are modules
that will do this sort of thing for you and to avoid any hairyness you
should consider using one of them.
HTH
John
-----Original Message-----
From: Octavian Rasnita [mailto:[EMAIL PROTECTED]]
Sent: 04 April 2002 14:03
To: [EMAIL PROTECTED]
Subject: Why it prints twice?
Hi all,
I made the following script for parsing an html file and get the addresses,
but they are printed twice instead of only once each one. Do you have any
idea why?
Here is the script:
$file="C:\\Program Files\\Apache Group\\Apache\\htdocs\\linux.htm";
open (IN, "$file");
while (<IN>) {
$line = /<a href=\"(.+)\">.+<\/a>/;
print $1;
print "<br>";
}
close IN;
I've made an .html file with a single address (link) to test the script, but
this script prints that address twice. It's just like when the script reads
each line twice.
Thank you for any help.
Teddy,
My dear email address is [EMAIL PROTECTED]
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------Confidentiality--------------------------.
This E-mail is confidential. It should not be read, copied, disclosed or
used by any person other than the intended recipient. Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful. If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]