in reply to What does it mean "$_." in PERL
The "$_" variable is described in perlvar. It's the default variable for many operators and functions.
This bit of code uses a variable:
while (my $line = <INFILE>) { print $line; print "FOUND IT!\n" if $line =~ /foo/; }
But if we wanted to use $_, we could rewrite the code as:
while (<INFILE>) { print; print "FOUND IT!\n" if /foo/; }
It's a very handy variable, but I only tend to use it in very small areas. I often find using a variable name to be a bit more clear and simple (for me) to maintain.
...roboticus
|
|---|