Hey,
I'm a bit confused with this (I'm a dinosaur..old dog, new tricks). Am I correct in thinking that, in the strict absence of being stated otherwise, any boolean comparisions are performed against $_ ?? In the example below "$_" is used as the basis of comparision for "if (/$pattern/)", ???
$_ = q("I wonder what the Entish is for 'yes' and 'no'," he thought.);
print "Enter some text to find: "; my $pattern = <STDIN>; chomp($pattern);
if (/$pattern/) {
print "The text matches the pattern '$pattern'.\n";
} else {
print "'$pattern' was not found.\n";
}
Boolean Validation in regards to $_
Started by inenigma, Apr 06 2010 02:24 AM
2 replies to this topic
#1
Posted 06 April 2010 - 02:24 AM
|
|
|
#2
Posted 06 April 2010 - 04:27 PM
Yes, I'm pretty sure $_ is used to compare by default. But why not use $_ =~ m/ etc just to be safe?
#3
Posted 07 April 2010 - 01:55 AM
Cheers. It's just that the example is from a text that I'm reading and I wanted to confirm my understanding of what it was comparing against to decide if it was TRUE or FALSE..


Sign In
Create Account

Back to top









