> I don't fully understand how, when or why to use the map function - > > my @file = ("line 1", "line 2", "line 3", "line 4", "line 5"); > my @test = map {/5/} @file; > > The result when I print @test is: > 1 > > As I understand things, this is the m/5/ being "true" Sorta. It's the length of the list resulting from map. Which is one. > Would it be fair to say we would use map when we > expect to have the expression return a list? Well, grep does that too. Grep: foreach element do match if match, add matched item to result list If you grep against a 10 element list, you get from zero to ten elements back. Map: foreach element do something add list of something's results to result list If you map against a 10 element list, you get from zero to infinite (sorta) elements back. > How would I go about creating a second array using map > or grep without changing the original? Can I do that at all? @foo = @bar;