![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: May 2005
Posts: 10
Rep Power: 0
![]() |
Determining a negative match
Hey i have a program where i needed to determine if something didnt match.
I originally tried using !=~ but no matter how many times i entered the string to match, it wouldnt work. i eventually replaced it with the not on the outside of the match and it now works. I would like to know why did !=~ fail to do what i wanted. This doesnt Work
$k = ""
while ($k !=~ /hello/i)
{
$k = <STDIN>;
}This Works $k = ""
while (!($k =~ /hello/i))
{
$k = <STDIN>;
}My question is whats the difference |
|
|
|
|
|
#2 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
It's been a while since I've used perl, but I believe !~ is the correct operator to use.
|
|
|
|
|
|
#3 |
|
Programming Guru
![]() ![]() ![]() |
Yep, !~ would work. The other issue was probably due to operator precedence, etc.
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|