BTW, the DATA filehandle is funny as well. This prints it's source along with line numbers (perl 5.8.8):#!/usr/bin/perl <DATA>; $.= 39; print "$. $_" while <DATA>; __DATA__ line 1 line 2 line 3
gives#!/usr/bin/perl seek DATA,0,0; print "$. $_" while <DATA>; __DATA__ line 1 line 2 line 3
1 #!/usr/bin/perl 2 3 seek DATA,0,0; 4 print "$. $_" while <DATA>; 5 __DATA__ 6 7 line 1 8 line 2 9 line 3
Bug or feature? :-)
cheers,
--shmem
Update: this is covered implicitly in perl561delta, Potential to leak DATA filehandles:
Using the "__DATA__" token creates an implicit filehandle to th +e file that contains the token. It is the program's responsibility to + close it when it is done reading from it.
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
In reply to Re: $. - smarter than you might think
by shmem
in thread $. - smarter than you might think
by GrandFather
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |