Hello everyone, I'm a very new user to perl, and naturally I have a very newbie question..
How does the special variable, ?_ work? I don't understand how it stores information, how you get it to store information, and what it stores exactly.
In the tutorial I'm using, the following is all I have to go on in terms of ?_
We could use a conditional as
if ($sentence =~ /under/)
{
print "We're talking about rugby\n";
}
which would print out a message if we had either of the following
$sentence = "Up and under";
$sentence = "Best winkles in Sunderland";
But it's often much easier if we assign the sentence to the special va
+riable $_ which is of course a scalar. If we do this then we can avoi
+d using the match and non-match operators and the above can be writte
+n simply as
if (/under/)
{
print "We're talking about rugby\n";
}
The $_ variable is the default for many Perl operations and tends to b
+e used very heavily.
How does the new regular expression (if (/under/) know what to grab from? Is it just the most recent object that was defined?
I apologize for (probably) asking such a silly question. I feel like I'm missing something very obvious and fundamental. Thank you in advance for any help you can give.