Hello i255d, and welcome to the Monastery!
Yes, this is one of many places where Perl uses the special $_ variable implicitly, making it easier to write concise, elegant code. For a list of the places where Perl uses $_ implicitly, see the first entry in perlvar#General-Variables. (If you’re not already familiar with the Perl documentation site, bookmark it now and get to know your way around as soon as possible.)
The Camel Book (4th Edition, p. 706) has this advice:
Use the singular pronoun to increase readability:
for (@lines) {
$_ .= "\n";
}
The $_ variable is Perl’s version of a pronoun, and it essentially means “it”. So the code above means “for each line, append a newline to it.”
Hope that helps,
| [reply] [d/l] [select] |
Very excited to be part of the Monastery. I am still on the llama book, chapter 13. Looking forward to the next one. I am an administrator, so I felt it best not to rush through the file and directory sections of this book. Yes, I think you have answered my questions.
I see someone ran my code through B::Deparse, later I will have to get into what that is.
| [reply] |
| [reply] |
Yes. If the argument is omitted, file test operators test $_ (except -t which tests STDIN).
| [reply] |