Hi,

Have you printed the variable $vars::name to be sure it contains what you
think it does?

Also, try the grep command:

open(LINKS, "$statedir/links.dat") or die "Error at LINKS: $!\n"
my @all_matches = grep (/$vars::name/, <LINKS>);
&print_link (@all_matches)

You can use arguments to grep to get inverse lists and such.

Lisa Wolfisch Nyman  <[EMAIL PROTECTED]>  IT Warrior Princess
"Life is too short to wear ugly underwear."
Get the facts at http://quickfacts.census.gov/

On Mon, 30 Jul 2001 [EMAIL PROTECTED] wrote:

> How can I test whether a person's name (which is the variable called
> $vars::name) is in a particular file  ( "links.dat")? The file is simply a
> list of names all separated by the newline character, i.e,
> 
> open(LINKS, "$statedir/links.dat") || die "Error at LINKS: $!";
> @people = <LINKS>;
> $pattern_to_match = "$vars::name";  #$vars::name is Harry, but the code
> won't find him
>    #$pattern_to_match = "Harry"; # the code will find Harry
> 
> for (@people) {
>       if ( /$pattern_to_match/) {
>               print "a match ";
>                } # end if
>       else {
>               print "no match  ";
>               &print_link; # print a hyperlink to the home page
>               } # end else
>  } #end for loop




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to