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:

  1. 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: $!";
  2. 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";
  3. 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,