#!/usr/bin/perl -w
use strict;

my $infile="file1.txt";  # input filename

print "Dude, where should I put output? ";
my $outfile = <>;
# This is optional, due to Perl magic:
# chomp $outfile;

open (OUT, ">$outfile")   or die "Dude, can't open $outfile for output: $!";

# Open; assign filehandle; exit on error:
open (IN, "<$infile") or die "Open of $infile failed: $!";

# Loop: read lines from the file
my $a;
#while ($a = <IN>) {
while ($a = <IN>) {
#    print;
    chomp $a;
#    print OUT $a . "\n";
    print STDERR $a . "\n";
}

# Clean up and exit:
close(IN);
close(OUT);
exit;
