http://www.perlmonks.org?node_id=629687


in reply to map split vs array split

I don't understand any of your questions, but I'll try and answer what it is I think you're asking. I beg your forgiveness if I'm wrong.

my @words = map { split } <FH>;

Four things are happening here...

Why is this evaluating split of array to scalar?

Because it's within a string. Perl evaluates print "\@lines1 is @lines1" as print '@lines1 is ' . @lines1. Concatenation forces scalar context on its operands. scalar @lines1 returns the number of element in the array.

See my reply below for the real answer to this.

print "@lines1" is treated magically: each element of @lines1 is printed, separated by a space.

update: ysth pointed out that what I'd written was wrong. Sorry about that.