in reply to Re: How does $. work in one liner?
in thread How does $. work in one liner?
There's nothing special about one-liners, not even the options which can be present in the shebang. The -n option on the other hand can make using $. a little more tricky, as it will not be reset from one file to the other if you are processing several at once. You can force it to be reset by closing the file handle as shown in eof, but personally at this point I would consider turning the one-liner into a .pl file. The $. issue is still true in a file script when using <>, but I haven't often seen it used to read from files rather than STDIN outside of a one-liner.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: How does $. work in one liner? -- it does not reset automatically
by Discipulus (Canon) on May 29, 2016 at 20:07 UTC |
In Section
Seekers of Perl Wisdom