Aaron Sherman writes: : On Mon, 2002-04-22 at 21:53, Larry Wall wrote: : : > * Parens always capture. : > * Braces are always closures. : > * Square brackets are always character classes. : > * Angle brackets are always metasyntax (along with backslash). : > : > So a first whack at the differences might be: : [...] : > space <sp> (or \h for "horizontal"?) : > {n,m} <n,m> : > : > \t also <tab> : : I want to know how he does this!!
Could have something to do with the fact that I've been banging my head against this for a couple of months already... : We sit around scratching out heads : looking for a syntax that fits and refines and he jumps in with : something that redefines and simplifies. Larry is wasted on Perl. He : needs to run for office ;-) Agh, no! I'm okay at simplifying, but I'm terrible at oversimplifying. : > \Lstring\E \L<string> : > \Ustring\E \U<string> : : This one boggles me. Wouldn't that be something like: : : <tolower string> or <tolower>string</tolower> # ;-) Well, <tolower:...> makes sense only if <> works in ordinary double quotes. : Seriously, it seems that "\L<prior>" would be confusing. Potentially, except that you almost never use it on anything but variable interpoations. So \L<$foo> would be a better example. The confusing thing is that $foo would not be assumed to be a regular expression, whereas it would in bare <$foo> (at least in a regex). : > \Q$var\E $var always assumed literal, so $1 is literal :backref : > $var <$var> assumed to be regex : : Very nice. I can get behind this, and a lot of people will thank you who : have to maintain code. Well, almost anything is an improvement over the current syntax. : > =~ $re =~ /<$re>/ ouch? : : If $re is a regexp, wouldn't "$str =~ $re" turn into "$re.match($str)"? : Perhaps "$re.m $str" which is no more typing and pretty clear to me. Sure, but I was illustrating the situation of a non-qr string being forced to be a regex. : > Obviously the <word> and <word:...> syntaxes will be user extensible. : > We have to be able to support full grammars. I consider it a feature : > that <foo> looks like a non-terminal in standard BNF notation. I do : > not consider it a misfeature that <foo> resembles an HTML or XML tag, : > since most of those languages need to be matched with a fancy rule : > named <tag> anyway. : : It's too bad that </tag> would be messy with standard Perl //-enclosed : regexes, as it would be a nice way to pass parameters to user-defined : tags. It would also allow XML-like propagation of results: : : <foo>x<bar>y</bar>z</foo> Gee, maybe we could make a way for people to use alternate dilimiters like they've always done with s///. :-) Larry