Help for this page

Select Code to Download


  1. or download this
    @array = <FILE>;
    $last_line = $array[$#array];
    
  2. or download this
    seek(FILE, -81, 2);             # 81 bytes from the end, which should 
    +be enough
    @lines = <FILE>;
    $last_line = $lines[$#lines];   # similar to above, but we don't read 
    +much
    
  3. or download this
    tie *FILE, File::ReadBackwards 'input_file';
    while (<FILE>) {
       # line-by-line starting from the end
    }