Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

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 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


Comment on Re: Could some explain =~ vs !~ to me?
Select or Download Code
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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (14)
As of 2014-09-17 14:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (82 votes), past polls