in reply to Perl Script help please
Hello ck346, and welcome to the Monastery!
First,
Now to the question of printing to a file. Do this in three stages:
Open the file for writing. Use the 3-argument form of open together with a lexical (my) filehandle, and check for errors:
my $output_file = 'demo.txt'; open(my $out_fh, '>', $output_file) or die "Cannot open file '$output_file' for writing: $!";
Print to the filehandle as you would to the console: just put the filehandle as the first argument to open, with no comma between the filehandle and the next argument:
print $out_fh "\$ENV{$key} = $ENV{$key}\n";
Close the filehandle when you’re finished writing to the output file:
close $out_fh or die "Cannot close file '$output_file': $!";
See perlopentut.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|