#!/usr/bin/perl

use strict;

# copy.pl
# check for correct number of arguments



if ($#ARGV != 1)
{
print "ERROR\n";
print "Correct format is: copy.pl inputfilename outputfilename\n";
exit;
}



my $input;
my $output;

$input=shift(ARGV);
$output=shift(ARGV);


#print "input is $input output is $output\n";


#read chapter 8 (I think) for other file tests

if (!(-f $input))
{
print "$input does not exist. Exiting program\n";
exit;
}


if(-f $output)
{
print "$output already exists. Exiting program\n";
exit;
}

open INPUT, "<$input" or die $!;

open OUTPUT, ">$output" or die $!;

my $line;
while($line=<INPUT>)
{
print OUTPUT $line;
}
close INPUT;

close OUTPUT;