in reply to uninitialized value warning and duplicating file handles
$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.
|
|---|