in reply to uninitialized value warning and duplicating file handles

You are using warnings which will give that error when you use an undefined value in a print statement (like print "hello $line\n" and $line is undef

$line is undef because at the time that you dup-ed HANDLE1 it was already at the end of the file (newfile.c only has one line in it.) So reading from HANDLE2 set $line to undef.

If you want to HANDLE2 to read from the beginning of the file you'll have to seek to the beginning ala seek(HANDLE2, 0, SEEK_SET). Note that doing this will not affect the position of HANDLE1.