Help for this page

Select Code to Download


  1. or download this
    open my $output, '>-' or die $!;
    
  2. or download this
    open my $output, '>&', *STDOUT or die $!;
    
  3. or download this
    open my $output, '>-' or die $!;
    close *STDOUT;
    print {$output} "This fails with Bad file descriptor";
    
  4. or download this
    open my $output, '>&', *STDOUT or die $!;
    close *STDOUT;
    print {$output} "This prints OK\n";
    
  5. or download this
    my $output = *STDOUT;
    
  6. or download this
    close STDOUT;
    print {$output}
        'Besides Bad file descriptor, this will also warn "print() on clos
    +ed filehandle STDOUT"';
    
  7. or download this
    #!/usr/bin/perl
    use strict;
    ...
    my $what = shift;
    my $code = $dispatch{$what} or die 'Not associated';
    test($code);