Hi List,

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,

Harry\n
Joe\n
Jane Doe\n

When I change my pattern-to-match to the literal string I'm testing for,
say, "Harry", the code works. But it NEVER finds "$vars::name" .

The code in question:

###
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

###

I've been reading up on regular expressions, pattern matching, etc. to no
avail. Any help would be greatly  appreciated. I have a feeling I am making
an obvious mistake but I can't figure out what it is.
Thanks.
--A Dogged Newbie




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

Reply via email to