> ... > or something odd > my $contents = do { local $/; map { chomp } <HANDLE> }; >
I'm afraid this, while appealing, in my testing generates an incorrect result, ie, 1. <SPECULATION> What happens I suspect is that the map{ } is in void context, not the scalar context of the outer do{}. Remember parsers are not as all-knowing as we'd like them to be. Therefore map churns merrily along and tosses its intermediate results until the final line. Only at that point does parser wake up and say "Aha, the do{ } wants scalar context so my final map{} value needs to be returned in scalar context. So here's what map{} does in scalar context. From 'perldoc -f map' : In scalar context, returns the total number of elements so generated. Evaluates BLOCK or EXPR in list context, so each element of LIST may produce zero, one, or more elements in the returned value. ^^^^ Remember, map has tossed all but the final value at this point so it just returns 1. Clear as mud? </SPECULATION> -- Charles DeRykus -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/