in reply to Re^3: "scalar found where operator expected" while printing to a glob ref
in thread "scalar found where operator expected" while printing to a glob ref

Yes, the block returning the dereferenced file handle is doing the job.

Even if it is not very explicit in the documentation, it is suggested in the last paragraph.
  • Comment on Re^4: "scalar found where operator expected" while printing to a glob ref