Perl-opening a file then copying files

Good morning guys!!

Im still practicing with Perl and now Im trying to open a file, and copy its contents to another file. Them I want to remeove the information out of the orginal file after it is copied over.

The flow should be messages-->messages1-->messages2.

Kind of like a log rotator.

Here is what I have:

#!/usr/local/bin/perl
$username = "rgoforth"
$filename = "/home/".$username."/messages";
$mess = "/home/".$username."/messages"/messages";
$mess1 = "/home/".$username."/messages"/messages.1";
$mess2 = "/home/".$username."/messages"/messages.2";
$mess3 = "/home/".$username."/messages"/messages.3";
$mess4 = "/home/".$username."/messages"/messages.4";

if (-e $filename){
        open (FILE, ">$mess") or die $!;
        print (FILE $mess1);
        close (FILE);
}else{
        print "Error: $filename doesn't exist\n";

But I cant seem to get past the strings. I have been looking at it for a while and I thought it might help to have some experts look at it.

Thanks
in advance!!

Ben

where are you opening a file for read ? normally that should be using <.

where are you going through the file to read ? normally that should be using while.