Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

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

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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://351672]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2018-01-23 01:08 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (238 votes). Check out past polls.