File input/output

Using filehandles for writing

Example:

#!/usr/bin/perl

open (OUT_FILE, ">out_file") || die "cannot open out_file: $!";
open (LOG_FILE, ">>log_file") || die "cannot open log_file: $!";

print OUT_FILE "Here is my program output\n";

print LOG_FILE "First task of my program completed\n";

print      "Done!\n";  # will be printed on the screen

close (OUT_FILE);
close (LOG_FILE);

Table of Contents.
Next | Next.