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!

Search problem

Status
Not open for further replies.

programingnoob

Technical User
Dec 31, 2002
71
CA
Hi,
I have this search problem. I just can't master the search functions...

I have this script

use warnings;
open IN, "results.htm" or die "error";
@content = <IN>;
close IN;

foreach $ln (@content) {

$ln =~ /.gif' width=30 height=30 border=1></a></td><td bgcolor='#ffffcc' align=left><a href='games.html?type=beat&shade_id=(\d+)'>/ && print;
$al[1]=$1;
$al[2]=$2;
$al[3]=$3;
$al[4]=$4;
$al[5]=$5;
$al[6]=$6;
$al[7]=$7;
$al[8]=$8;
$al[9]=$9;
$al[10]=$10;
$al[11]=$11;

}

I got lots of errors.

However, i soon found out the the \ can be used to eliminate some of tthe errors. But I don't know where to put them. Also, I need the search results to be the numbers, which is (\d+) (\d is a shortcut for numbers and + means any quanity). And () means save it to $1
However, I'm sure that there will be more than result, how can I save them all?

Thanks
 
Correction:

The search should bring more than 1 result. And I used (\d+) to save it to $1, $2, $3.... so on. However, I am not sure if this works, because there will be more than 1 line that will match this search. Will the last match on the last line override all the previous matches on the previous lines? I am not sure, because I do not know how $1 works. Also, should I put the searched document (result.htm) into a scalar variable instead? That way, I can search through the entire document in 1 search only, so all the $1, $2 won't have a chance to be override, but, the $1 might be deleted before it gets saved to another variable... hm...

Can anyone solve my problem and fix the search part?

Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top