in reply to uninitialized value warning and duplicating file handles

I ran your code on my system (with a "newfile.c" that had four lines), and I had no problem. If I run with a file that has only one line, I get the output you get. In that case, when you do:

$line=<HANDLE2>;

...$line contains undef because HANDLE2 is, like HANDLE1, at end of file.

Then when you use line in the following print:

print "hello $line\n";

That's when you get the warning. Note that you'd get the warning any time you try to interpolate that variable (carrying the special undef value), even if it's not being printed.