Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Could some explain =~ vs !~ to me?

by krusty (Hermit)
on May 08, 2004 at 02:52 UTC ( [id://351672]=note: print w/replies, xml ) Need Help??


in reply to Could some explain =~ vs !~ to me?

Zaxo is right with his explanation, but what I don't understand is your output.

I would expect the last line of output to be WooWoo

Using your last few lines of code here's my output using perl 5.8.3
Useless use of not in void context at test.pl line 7. WooWoo

What happens is that the negated pattern bind operator substitutes the first capital "H" it finds in "WooHoo".
I am evaluating whether the substitution was *not* successful, but since I do nothing with the result I get a the void warning. Since my string has changed I now print "WooWoo". I would have expected your code to print "WooWoo" too.

I'm going to quit now because this sounds a bit too much like a Dr. Seuss book.

Cheers,
Kris

Thanks duff. I see now what the problem is. In my code, I'm taking only a few snippets of the original code. If I take the whole code, I'm working on the modified string "HooHoo" at the time, and would need a /g modifier to get both "H"'s

Replies are listed 'Best First'.
Re: Re: Could some explain =~ vs !~ to me?
by duff (Parson) on May 08, 2004 at 03:11 UTC
    You must be doing something different than the OP if you get WooWoo. There are no /g modifiers on those substitutions and the string looks like HooHoo before he does the final substitution.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://351672]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-04-25 18:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found