Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Regex During Map Function

by samarzone (Pilgrim)
on Dec 15, 2010 at 14:52 UTC ( #877285=note: print w/ replies, xml ) Need Help??


in reply to Regex During Map Function

You can use grep to filter out empty values

%params = map { $_ => join("; ", grep {$_} split("\0", $cgi->Vars->{$_})) } $cgi->param;

-- Regards - Samar


Comment on Re: Regex During Map Function
Select or Download Code
Re^2: Regex During Map Function
by AnomalousMonk (Abbot) on Dec 15, 2010 at 16:23 UTC

    Remember, however, that '0' is false, hence will be filtered out. Better, perhaps, to use
        grep { length $_ }

Re^2: Regex During Map Function
by deMize (Monk) on Dec 20, 2010 at 14:51 UTC
    I don't want to filter out all empty values, though. Just the leading of a multi-valued element.

    If a form control has a bunch of checkboxes w/ the same element name, I want them all. I also want the blank values for those elements that don't have multiple values.

    For some reason there's an empty value for a multi-valued list control.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://877285]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (10)
As of 2015-07-02 05:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (29 votes), past polls