home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / perl / 7415 < prev    next >
Encoding:
Internet Message Format  |  1992-12-14  |  2.5 KB

  1. Path: sparky!uunet!paladin.american.edu!europa.asd.contel.com!emory!swrinde!zaphod.mps.ohio-state.edu!sdd.hp.com!spool.mu.edu!olivea!sgigate!sgi!wdl1!wdl39!mab
  2. From: mab@wdl39.wdl.loral.com (Mark A Biggar)
  3. Newsgroups: comp.lang.perl
  4. Subject: Re: In 5.0, are we gonna get...
  5. Message-ID: <1992Dec14.192007.7534@wdl.loral.com>
  6. Date: 14 Dec 92 19:20:07 GMT
  7. References: <1992Dec14.043835.23009@reed.edu>
  8. Sender: news@wdl.loral.com
  9. Organization: Loral Western Development Labs
  10. Lines: 50
  11.  
  12. In article <1992Dec14.043835.23009@reed.edu> mjeffery@reed.edu (Mark Jefferys) writes:
  13. >Will we see:
  14. >
  15. >1) an equivalent of lisp's mapcar?  For an instance:
  16. >
  17. >    map(/(\d+)/, "asdf 23fjk4", "qwerty", "123 ")
  18. >
  19. >   would return ("23", "4", "123").
  20.  
  21. Easily constructed using grep:
  22.  
  23.         grep((/(\d+)/,$_=$1), "asdf 23jfk4", "qwerty", "123 ")
  24.  
  25. produces ("23", "123") (Even lisp's mapcar only applies the function once per
  26. sequence item.)  Larry has talked about adding a 'reduce' operator that
  27. calls a special sort like function (used $a,$b for arg passing) on each element 
  28. of a list for doing summations like so:
  29.  
  30.     $sum = reduce {$a+$b} 1,34,$x,45,-8,0.1;
  31. >
  32. >2) a way of only matching the real beginning/end of a *string* in a
  33. >   regexp?  Currently, '^' and '$' match the beginning and ending of
  34. >   a line (with simplifying assumptions when $* == 0).  A string match
  35. >   would ignore newlines and $*.
  36. >
  37. >   A new option on pattern matches might do it:  `/^\d+$/s' might match
  38. >   "23", but not "23\n" or "x\n45".  The option should treat `.' as
  39. >   matching "\n", as well as every other character -- so the option
  40. >   means that "\n" should not be treated specially. 
  41.  
  42. I believe that ^ at the beginning of a pattern will only match the beginning
  43. of a string and $ at the end only the end, $* has effect only on embedded
  44. ^ and $ in the middle of a pattern.
  45. >
  46. >3) a pure grouping operator in pattern matches.  Normally, `/Type:
  47. >   (\d+|[a-zA-Z])/' will return an element containing the
  48. >   `\d+|[a-zA-Z]' (in an array context), and assign $1 to the pattern.
  49. >   If this isn't wanted, it will only slow perl down, and possibly
  50. >   make life confusing if the pattern is very complex.  One that
  51. >   doesn't try to save its contents would be nice.
  52.  
  53. Larry and I have also talked about this, possibly using < > as the grouping
  54. chars, as well as **, ++, and {n-m} which would be minimal length matching
  55. versions of the current maximal length matching *, + and {n,m} and possibly
  56. a prolog like cut operator (!?) to limit backtracking in patterns.
  57.  
  58. --
  59. Perl's Maternal Uncle
  60. Mark Biggar
  61. mab@wdl1.wdl.loral.com
  62.