in reply to Scanning a file and extracting certains values within one or multiple lines

Here you read in the whole file:

open(FILE1, $ARGV[0]) || die "Error: $!\n"; @lines = <FILE1>;

... and here you try to read some more, which fails:

while ($line=<FILE1>){

Often it helps to add debug print statements to show you the progress of your program, so you see which loops it enters and which it skips.