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


in reply to Map: The Basics

I like this tutorial. Good info. I did find a few minor errors, however, which I'll enumerate below.

my @lines = map { split } <FILE>;

should probably be

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

Check all your uses of "it's". "It's" is a contraction of "it is". The possessive is "its". So, any time you're showing possession (such as in "split uses whitespace as it's default delimiter, and the special variable $_ as it's default variable"), "it's" should be "its". Ain't English wunnerful?

Your third code sample, "my @lines = map { split(/\s/, $_) } <FILE>;", is not equivalent to the second. split(/\s/, $_) is not the same as raw split. It should be split(' ', $_), taking advantage of the special meaning of ' ' inside split.

Toward the end, you say, "chomp returns true or false". Not quite correct. chomp returns the number of characters it chomped.

And finally, a few misspellings, if you don't mind:

"lightening" should be "lightning"
"usefull" should be "useful"
"headeaches" should be "headaches"
"seperated" should be "separated"

Overall, good stuff. Have a Scooby snack on me.

*Woof*