Help for this page

Select Code to Download


  1. or download this
    open FH, '<', 'file.txt' or die ("Can't read file: $!");
    
    until( eof(FH) ) {
      print <FH>;
    }
    
  2. or download this
    open FH, '<', 'file.txt' or die ("Can't read file: $!");
    
    ...
    #loop ends automatically when you reach EOF
    printf "File had %d lines, with an average length of %d chars\n",
       $lines, ($total_length / $lines);