SPUG: idioms of late

Michael R. Wolf MichaelRWolf at att.net
Tue Jan 19 00:17:12 PST 2010


On Jan 18, 2010, at 8:10 PM, Andrew Sweger wrote:

[...]

> for using
> the DBI/DBD quote method (as opposed to the insane DIY one I found  
> in some
> legacy code!).


And, while you're talking about DIY in maintained code, remember that  
Gisle has created a bunch of great URI manipulation routines, so  
there's no need to escape them yourself...


$ perl -MURI::Escape -e 'print uri_escape(chr($_)) foreach 0..0x7F'
%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F 
%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20!%22%23%24%25%26'()* 
%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B 
%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F
$

(It'll go up to 0xFF without needing to use uri_escape_utf8(), but  
it's not really interesting above 0x7F)

Who's got the time to look 'em all up and get 'em right?  Not me.   
Great set of routines, those URI::* modules.

I've seen some code that has to munge this to conform to PHP  
conventions (e.g. s/%20/+/g), but I'd still rather start with the  
standard instead of a DIY.

-- 
Michael R. Wolf
     All mammals learn by playing!
         MichaelRWolf at att.net






More information about the spug-list mailing list