Plankton has asked for the wisdom of the Perl Monks concerning the following question:
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. |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Could some explain =~ vs !~ to me?
by Zaxo (Archbishop) on May 08, 2004 at 02:16 UTC | |
|
Re: Could some explain =~ vs !~ to me?
by fizbin (Chaplain) on May 08, 2004 at 03:30 UTC | |
|
Re: Could some explain =~ vs !~ to me?
by krusty (Hermit) on May 08, 2004 at 02:52 UTC | |
by duff (Parson) on May 08, 2004 at 03:11 UTC |