? Earlier 2 items total Later ?

On this page:?

Parse comma separated data

Import data in CSV format. Normally an easy task using split but sometimes, the fields will have comma's enclosed by quotes.
Something like.
Aaron, "123 Main St, USA", 555-555-1212
Assuming your string gets put into $text.
    my @new  = ();
    push(@new, $+) while $text =~ m{
        # the first part groups the phrase inside the quotes.
        # see explanation of this pattern in MRE
        "([^\"\\]*(?:\\.[^\"\\]*)*)",?
           |  ([^,]+),?
           | ,
       }gx;
       push(@new, undef) if substr($text, -1,1) eq ',';

Taken from Jeffrey Friedl's Mastering Regular Expressions

Encode and Decode strings from URL.

Encode a string so that it's safe to be passed in a url. Equivalent of urlencode in PHP.
$str =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;


Now, the reverse, decode a string from a url. Equivalent of urldecode in PHP.
$str =~ s/\%([A-Fa-f0-9]{2})/pack('C', hex($1))/seg;

? Earlier 2 items total Later ?