Help for this page

Select Code to Download


  1. or download this
    open my $fh, ">output.txt"
        or die "Can't create output: $!";
    print {$fh} "Hello world!\n";
    close $fh;  # if don't close, then it will be closed
                # automatically when $fh is out of scope.
    
  2. or download this
    my $fh = IO::File "output.txt", "w"
       or die "Can not create output: $!";
    print $fh "Hello world!\n";
    undef $fh;