Help for this page

Select Code to Download


  1. or download this
    open my $input, '<', 'myfile.txt'
        or die "cannot open myfile.txt: $!";
    my @lines = <$input>;
    
  2. or download this
    my $filename = $ARGV[0]
        or die "Usage: $0 <filename>\n";
    open my $input, '<', $filename
      or die "cannot open $filename: $!";
    my @lines = <$input>;