if I want to print the line number of a file I did this:
while(<>){ print "$.\n" }
it works fine. However, if I try to use "map":
map{print "$.\n"}<>;it can only print the last(or total) line number.
Does anyone know why this happens? How should I (or Can I)use "map" or "grep" to get or the line number of a file using "$."?
Thanks.
In reply to Different behaviors between "while" and "map" by lightoverhead
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |