try this.
#!/usr/bin/perl -w
use strict;
my $output_file = "out.txt";
my $user_input = "";
my $quit_code = "quit\n";
open(OUTPUT, ">$output_file) ||
die "Unable to open $output_file for writing: $!\n";
while ($user_input ne $quit_code)
{
print "Enter some text: ";
$user_input = <STDIN>;
print OUTPUT $user_input;
}
close(OUTPUT) ||
die "Unable to close $output_file: $!\n;