Mega Code Archive

 
Categories / Perl / Language Basics
 

Using the Default Variable $_

#When you use the construct <STDIN> without assigning, Perl assigns that return value to a variable named $_.  #Many Perl functions use this special variable, called the default variable. #You can use the print function without specifying a variable at all to print the contents of $_.  while($_ = <STDIN>) {    print $_; }