XP is just a number | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
In fact Eily is precise as always elevenfly, and he pointed exactly where $. is special in oneliners.
He gave you the definition, i'll add an example. Given a.txt and b.txt as following: if you use $. to check line number (and $. is implicit for a bare .. flip-flop operator), you have: and so is because $. does not reset automatically for an implicit close of the filehandle (and -n iterates across file given as arguments and reopen each time ARGV so without explicitly closing it). But if you use the right idiom close ARGV if eof everything runs as expected: $. is reset by the explicit close that happens only if eof is encounterd:
L*
There are no rules, there are no thumbs.. Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS. In reply to Re^3: How does $. work in one liner? -- it does not reset automatically
by Discipulus
|
|