in reply to Writing to an output file

I would recommend you read through perlintro, it's not very long and it shows how to do basic file I/O, for example:

my $filename = "output.txt"; open my $fh, '>', $filename or die "$filename: $!"; print $fh "Hello"; close $fh;