This is not the cleanest example, but hopefully it will get you going in the right direction....
#!/usr/bin/perl use strict; my $file = "/path/to/file"; # location of the file my $firstword = "foo"; # 1st search word my $firstlocation = "http://www.location1.com"; # 1st URL my $secondword = "bar"; # second search word my $secondlocation = "http://www.location2.com"; # 2nd URL open(INFILE,"<$file") or die "Could not open file"; # read the file my @query = <INFILE>; # slurp it into an array close(INFILE); # close it # probably could have done this with 'while(<INFILE>)' # to condense but I prefer iterating through with 'for' print "Content-type: text/html\n\n"; # print HTTP header for my $line(@query) { # search the lines for the 2 keywords my($one,$two,$three,$four) = split(/,/,$line); # split at commas # Assumes 4 columns, I have no idea what your real situation is if ($one =~ /$firstword/) { # searches the 1st column for 1st word print "Location: $firstlocation <br>"; } elsif ($one =~ /$secondword/) { # searches 2nd column for 2nd word print "Location: $secondlocation <br>"; } else { print "<hr>"; } } -----Original Message----- From: Matthew Harrison [mailto:[EMAIL PROTECTED]] Sent: Friday, March 22, 2002 3:26 PM To: [EMAIL PROTECTED] Subject: my first regex i think if i have a file delimited by commas and i want to make a script that will search to see if a word, passed in a query string, is in the file, and redirect to one url if i does and one if it doesn't (both urls are also passed via query strings) thanks in advance -- Matthew Harrison Internet/Network Services Administrator Peanut-Butter Cheesecake Hosting Services Genstate www.peanutbuttercheesecake.co.uk -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.333 / Virus Database: 187 - Release Date: 3/8/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.333 / Virus Database: 187 - Release Date: 3/8/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]