142

Input/Output
Default File Handles

  • When the Perl interpreter starts running your script it automatically opens several useful default file handles

      Name Desription
      STDIN For reading from the keyboard or default input stream
      STDOUT For (buffered) writing to the terminal or default output stream
      STDERR For (unbuffered) writing to the terminal or default error stream

  • We have seen basic use of these default file handles

      $line = <STDIN>; # Reads one line from STDIN

      print STDOUT "Hello World\n"; # Writes one line to STDOUT

  • Now lets see the details for the use of arbitrary file handles...