Basic problem

Hello Friends,

I am learning Perl now. I have a small query.

I have a directory Z with file name Z.txt.
I would like to copy this file Z.txt to 3 new dir with new filenames as follows
dir 1 1.txt
dir 2 2.txt
dir 3 3.txt

I would like to then open 1.txt from dir 1 and edit the first 4 lines and it
would be better if the program can ask me what to enter in these lines. I need to do the same for all the directories.

For eg: I have a line as follows.
x y Z
10 11 12

Th program should ask me what to enter for Y value. So when the program asks, Igive it a new value.

I have tried the following and I guess there is a much shorter way to do this

#!/usr/bin/perl
open FILE, "z.txt" or die $!;
while (<FILE>) {
print $_;
}
mkdir("1", 0777) || print $!;
copy("z.txt","1.txt") or die "Copy failed: $!";
move("1.txt","/home/privat/temp/PerlWD/1");
mkdir("2", 0777) || print $!;
copy("z.txt","2.txt") or die "Copy failed: $!";
move("2.txt","/home/privat/temp/PerlWD/2");
mkdir("3", 0777) || print $!;
copy("z.txt","3.txt") or die "Copy failed: $!";
move("3.txt","/home/privat/temp/PerlWD/3");
print " -Done";
exit;

I am not sure how to edit the file and then save it in the respective file name.

Looking forward to your response.

Regards,
Ramesh