Perl demands that whatever appears inside the <> operator be a simple scalar value -- no subscripts or expressions allowed. You've "stumbled" upon
a common workaround for this limitation. Another one would be to use a module like IO::Handle or IO::File, so that you can use the readline method of the objects instead.