in reply to Where does <GEN1> come from?

The bit on the end indicates the most recent line of the most recent file read. In the case shown, the main script probably has lines that looks something like:

open GEN1, ... while( <GEN1> ) { ... }

From perlfunc for die:

If the last element of LIST does not end in a newline, the current script line number and input line number (if any) are also printed, and a newline is supplied. Note that the ``input line number'' (also known as ``chunk'') is subject to whatever notion of ``line'' happens to be currently in effect, and is also available as the special variable $..

It's a barely documented and somewhat dubious feature.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

Replies are listed 'Best First'.
Re^2: Where does <GEN1> come from?
by blazar (Canon) on May 24, 2007 at 19:12 UTC
    It's a barely documented and somewhat dubious feature.

    Personally I find it an useful feature. However I hardly ever remember having used it: more precisely most of my warnings and errors are meant for the users of some script. Thus I end them with "\n". In the rare case I have some that are meant for people working on the script itself, I don't append it. A tiny example was posted here.

      The default of appending the line number at which a message is generated is a fine and useful feature.

      The default of also appending the filehandle and linenumber of the last line of the last "file" read by the script, or any of the modules it uses, is at best dubious, at worst, confusing.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.