Help for this page

Select Code to Download


  1. or download this
    use strict;
    use warnings;
    ...
    my $file = shift or die "usage: $0 file\n";
    tie my @lines, 'Tie::File', $file or die "error: $!";
    print $lines[$#lines];   # this is the last line in the file
    
  2. or download this
    use Fcntl 'O_RDONLY';    # add this line
    #   ... as before, then change the tie line as shown below
    tie my @lines, 'Tie::File', $file, mode => O_RDONLY or die "error: $!"
    +;
    #   ... as before