in reply to Is there a better way of dealing with !~ and "Useless use of not in void context at" warnings?
But in general, you can get rid of "Useless use of...in void context" by giving a non-void context. The easiest way to do this is
In 5.6.0 and earlier, this didn't work, but I think this did:scalar( $str !~ s/junk//g );
(The constants 0 and 1 are exempt from the "Useless use" warning.)1 if $str !~ s/junk//g;
|
|---|