in reply to Back to Remedial Perl for Me: map{} function
Question for the monks:
Isn't it true you could do something like this (even though it's probably not in keeping with the intent of map)?
# a way to count the number of elements in a list my $count = 0; my @listOfThings = ('one', 'two', 'three'); map { ++$count } @listOfThings; print "There are $count things in your list of things.\n";
This example completely ignores the fact that the elements in the list are assigned to $_. We could care less what was in those elements. All we want to do is to execute this block once for each element that is in the list.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Back to Remedial Perl for Me: map{} function
by merlyn (Sage) on Dec 15, 2000 at 22:00 UTC | |
by Anonymous Monk on Dec 16, 2000 at 04:08 UTC |
In Section
Seekers of Perl Wisdom