Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

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

by krusty (Hermit)
on May 08, 2004 at 02:52 UTC ( #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 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.


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

Comment on Re: Could some explain =~ vs !~ to me?
Select or Download Code
Replies are listed 'Best First'.
Re: Re: Could some explain =~ vs !~ to me?
by duff (Vicar) 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?

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (1)
As of 2015-10-09 05:03 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (233 votes), past polls