[Melbourne-pm] nearly there...

Mathew Robertson mathew.robertson at netratings.com.au
Thu Dec 20 14:50:43 PST 2007


>>> only if they can't read perl.
>>>       
>> nobody can read Perl... :)
>>     
> lots of people can.  it's kind of a requirement for writing it well.
>   
whoosh....
>> except that using your http example, you can't parse url arguments
>> (without escaping) 
>>     
>
> 1. i wouldn't. using regexps to parse CGI args is a bad idea. that's
> what CGI or any one of several other CGI arg parsing modules are for.
>   
obviously - but since you brought up the example, you cant then turn
around and point fingers...
> 2. for the sake of the argument, if i were to be writing a Q&D hack
> to do that, i would (as i mentioned in my previous msg) use another
> separator. '|', perhaps. or maybe '-'.  or something.
>
> depends.  my personal aesthetic says if i have to escape a character
> more than once or twice then use a different separator.
>   
>> and the ugliness-factor would but much worse.  Perl
>> POD often uses '!'... maybe that is a good character to use?
>>     
> or '!', even if it does feel a bit over-excited.  B1FF-mode regexps.
>
>   
>>>> Use curly braces instead:
>>>>         
>>> i find that ugly inside regexps, and don't/won't do it. curly braces
>>> are for hashes or code blocks etc, not for uglifying regexps.
>>>
>>> i'll use pretty nearly anything else before i'll use them.
>>>       
> also, curly braces have a meaning inside regexps - they're for
> specifying the number of times to match.  
>
>     {n}?   Match exactly n times
>     {n,}?  Match at least n times
>     {n,m}? Match at least n but not more than m times
>
> i use them all the time, especially the latter two forms.
>
>   
>>> YMMV, but to me, that is significantly less readable.
>>>       
>> The POD contains many references where using balanced brackets is a
>> good thing - it would be only you that considers them ugly.
>>     
>
> 1. what can i say?  i have good taste where some others don't :-)
>
> (and i don't consider all curly braces ugly - just using them as regexp
> boundaries)
>
> 2. POD has such examples inside regexps?
>   
perlre has examples using {} <>, perlop uses {}

And if you consider the 'tr' operator in a similar vein, perlop uses []
<> {}

perlop even has one example where two different brackets are used in the
same operation, as in:

  $program =~ s {
    ...
   } []sgx;


Mathew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/melbourne-pm/attachments/20071221/a616542a/attachment-0001.html 


More information about the Melbourne-pm mailing list