in reply to Different behaviors between "while" and "map"

Does anyone know why this happens?
Context. The guard of a while is in scalar context, all argument following the block of map are in list context. And the diamond operator reads one line in scalar context, and all the lines in list context.
How should I (or Can I)use "map" or "grep" to get or the line number of a file using "$."?
Count the lines yourself:
my $count = $. - 1; map {++$count; your statements here} <>;