in reply to Is there a better way of dealing with !~ and "Useless use of not in void context at" warnings?

That construct is tres-weird. I didn't even know it would work. Learn something new. :) I'd say, just use =~ like Dog intended.

perl -wle '$str = "not junk"; $str !~ s/junk//g; print $str' Useless use of not in void context at -e line 1. not perl -wle '$str = "not junk"; $str =~ s/junk//g; print $str' not
Update: the warning in 5.10 is a bit more informative than the one in 5.8 too: "Useless use of negative pattern binding (!~) in void context at -e line 1."
  • Comment on Re: Is there a better way of dealing with !~ and "Useless use of not in void context at" warnings?
  • Select or Download Code

Replies are listed 'Best First'.
Re^2: Is there a better way of dealing with !~ and "Useless use of not in void context at" warnings?
by Plankton (Vicar) on Jan 25, 2009 at 05:53 UTC
    Oh yeah ... I got in my head some how that one should use !~ to "remove" or "negate" patterns and =~ to "match" or "find equivalent" patterns. Thanks for clearing away the bad burn in.