Help for this page

Select Code to Download


  1. or download this
    $ perl -E 'open my $fh, ">", "xxx"; close $fb; open my $fh, ">", "yyy"
    +'
    $
    
  2. or download this
    $ perl -E 'use strict; use warnings; open my $fh, ">", "xxx"; close $f
    +b; open my $fh, ">", "yyy"'
    "my" variable $fh masks earlier declaration in same scope at -e line 1
    +.
    ...
    Execution of -e aborted due to compilation errors.
    ken@ganymede: ~/tmp
    $
    
  3. or download this
    $ perl -E 'use strict; use warnings; { open my $fh, ">", "xxx"; } open
    + my $fh, ">", "yyy"'
    $
    
  4. or download this
    use strict;
    use warnings;
    
  5. or download this
    die "CANNOT OPEN LOG";
    
  6. or download this
    die "CANNOT OPEN LOG '$logfilename': $!";
    
  7. or download this
    select $fh;
    print "...";
    ...
    print "...";
    select STDOUT;
    print "...";
    
  8. or download this
    print $fh "...";
    print STDERR "...";
    print "...";
    
  9. or download this
    my $open_ok = open my $fh, $mode, $filename;
    if (not $open_ok) {
        # custom error handling here
    }
    
  10. or download this
    #!/tps/bin/perl
    
    ...
        print $fh "...";
        print "...";
    }