Here's the ouput ...#!/usr/bin/perl -w use strict; my $var = "WooHoo\n"; # I know that this will print ... print $var if $var =~ /^Woo/; # and I know that this will print ... print $var if $var !~ /^Hoo/; # and I think I understand whats # going on here ... $var =~ s/W/H/; print $var; # But I didn't expect this ... $var !~ s/H/W/; print $var;
It does complain a bit about void context ... but so what? Could somebody enlighten me?Plankton@linux:~/perl/perlmonks> ./tilda_q.pl Useless use of not in void context at ./tilda_q.pl line 18. WooHoo WooHoo HooHoo WooHoo
| Plankton: 1% Evil, 99% Hot Gas. |
In reply to Could some explain =~ vs !~ to me? by Plankton
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |