One way is that you can use eq instead of =~.  If there is a reason you
can't use eq then you can use /^name$/.  That will cause it only to match
the string name.  BTW, eq does an exact string match while =~ does a pattern
match.

To illustrate the difference, consider the following lines

print "1" if "merry christmas" eq "chris";
print "2" if "merry christmas" =~ /chris/;
print "3" if "merry christmas" =~ /^chris$/;

This will print out 2, but not 1 or 3.

print "1" if "chris" eq "chris";
print "2" if "chris" =~ /chris/;
print "3" if "chris" =~ /^chris$/;

This will print out 123.

You can look at perldoc perlre for regular expression help and 
perldoc perlop for help on eq and its relatives.

Hope this helps!
Tanton

-----Original Message-----
From: HANSON
To: [EMAIL PROTECTED]
Sent: 11/9/2001 5:46 PM
Subject: basic pattern matching

Hi gurus!

I am traversing a multidimensional hash searching for a value and 
trying to delete it. However, I am ending up deleting the wrong one. 
The value I'm looking for is /name/. There is also a value of /name1/ 
in the hash. When I use =~/name/ it deletes the name1 value somehow. 
Is there a way I can be very specific and keep it from deleting the 
name1 value?

Thanks!

-mark

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

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

Reply via email to