Help for this page

Select Code to Download


  1. or download this
    open FILE, "foo" || die "can't open file"; # assume -T foo
    
  2. or download this
    open FILE, ("foo" || die ...)
    
  3. or download this
    open( FILE, $file) or die "Error: can't open file '$file': $!\n";
    
  4. or download this
    open( FH, $file1 ) or die $!;
    while( my $line1 = <FH> ) {
    ...
    close( FH );
    <code>
    <p>gives you an error because the first <code>close( FH );
    
  5. or download this
    open( my $FILE, $file )
      or die "Error in reading file '$file': $!\n";
    ...
      print "$.: $line\n";
    } # while
    close( $FILE );