--- Tom Phoenix <[EMAIL PROTECTED]> wrote:
> On 9/10/06, chen li <[EMAIL PROTECTED]> wrote: > > > Although I read the usage for grep and map using > > perldoc -f grep or map I don't think I really get > the > > differences between them. > > The expression in a map is evaluated in a list > context. The list that > it returns is included in the result list. > The expression in a grep is a Boolean value, so it's > evaluated in a > scalar context. If it's true, the corresponding > value from the list > (that is, the value of $_ inside the expression) is > included in the > result list. > > These properties make grep useful for simply > selecting elements from a > list, while map is able to transform a list in a > more general way. > > Does that give you what you needed? Hope this helps! > > --Tom Phoenix > Stonehenge Perl Training > So map function returns the transformed or changed elements but not the original ones and grep still returns the original ones? For example after certain operation A changes to B, in case of map the return is B but in case grep the return is still A. Is that right? Thanks, Li __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>