>>>>> "EW" == Erik Witkop <ewit...@gmail.com> writes:

  EW> Thanks Uri.
  EW> It is time that I learned map. I typically lean on grep and =~ for
  EW> matching patterns. But map sounds like a great solution.

grep is NOT a regex function or has anything to do with regexes. get
that false association out of your head. grep is a filter. period. its
first arg CAN be a regex but it can be any perl expression or code
block. regexes are commonly used with grep but they are not builtin to
grep. grep treats regexes like any other expression.

also =~ is not a regex op, but a binding one. it also binds a value to
tr/// which is not a regex. but if the right side of =~ is not tr///,
m// or s///, it will treat it like it is a regex.

and map is more important to your personal perl toolkit than grep. you
can write grep with map but you can't the other way around. this means
map is more powerful, flexible and useful than grep. not that i don't
use grep but i use map much more often since you transform lists more
often than you filter them. think of filtering as one of many possible
transforms.

uri

-- 
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to