[Melbourne-pm] nearly there...

Mathew Robertson mathew.robertson at netratings.com.au
Wed Dec 19 22:28:06 PST 2007


>>> if it bothers you, then strip out the extras yourself:
>>>
>>>          my $full_path = "$dirname/$entry";
>>>          $full_path =~ s=//=/=g;
>>>       
>
> it's wrong (at least, sub-optimal), anyway.  should be:
>
> $full_path =~ s=//+=/=g;
>
>   
>> Except, don't use = as your separator.  It breaks people's brains.  
>>     
>
> only if they can't read perl.
>   
nobody can read Perl... :)
> i use = (when i don't use /) because it's one of the characters least
> likely to appear as a character literal in a regexp also containing /
> character literals. 
>
> e.g. any regexp containing a literal / (which is why i'm using another
> char as the separator, to avoid the unreadable ugliness of lots of \
> escaping) is fairly likely to also have : characters ("http://.....")
>
> '=' also has the significant advantage of being visually distinct from
> most other characters (no highs or lows, just a horizontally centred
> double-bar so it highlights the separation almost like whitespace). 
>
> '-' works reasonably well too.
>
> if the regexp has literal = characters too, i'll use something else.
>
> the whole point is to make the regexp more readable.
>   
except that using your http example, you can't parse url arguments
(without escaping) and the ugliness-factor would but much worse.  Perl
POD often uses '!'... maybe that is a good character to use?

>> 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.
>
>
>   
>> 	$full_path =~ s{//}{/}g;
>>     
>
> the point of using a different separator is to make the regexp more
> readable, not less.
>
> 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.

Mathew

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/melbourne-pm/attachments/20071220/5ae2ed80/attachment.html 


More information about the Melbourne-pm mailing list