FILE is the file handler for the file that you are reading. When you want to process a file, you have to change/redirect the input stream/ output stream to the file. For this purpose, a file-handle is created when you use open() function.
-
open(FILE,"data.txt") or die "opening file failed";
-
When you assign this file-handle within angular brackets to an array
The array would contain entire content of file with each line in file as each element in the array(as '\n' is the default input record separator)
When you assign it to a scalar, it would contain the first line of file:
In your code, while(<FILE>) {} loop will iterate through the file, one line at a time.
I would suggest you to go through
Files and Data