mellin has asked for the wisdom of the Perl Monks concerning the following question:
So bits and pieces like this:# three text inputs, each with a size 30 tag form('input', 'text', 'user_name:Name', '30', 'user_email:Email|format + user@domain.com', '30', 'user_title:Topic', '30'); # textarea element, size 30 cols x 10 rows form('textarea', 'user_message:Feedback', '30x10'); # select element, name 'city', four options form('select:sort', 'city:City', 'Tampere', 'Helsinki', 'Espoo', 'Turk +u'); # input checkbox form('input', 'checkbox', 'reply|waiting for answer?'); # input submit form('input', 'submit', 'send');
What characters should i choose to be delimeters, and how could this be made "foolproof"?sub split { my %key; if ($_[0] =~ /^(.+?):(.+?)$/) { $key{'name'} = $1; $key{'definition'} = $2; $key{'altdefinition'} = ''; } elsif ($_[0] =~ /^(.+?)\|(.+?)$/) { $key{'name'} = $1; $key{'altdefinition'} = $2; $key{'definition'} = ''; } elsif ($_[0] =~ /^(.+?):(.+?)\|(.+?)$/) { $key{'name'} = $1; $key{'definition'} = $2; $key{'altdefinition'} = $3; } return %key; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Getting regular expression right
by blazar (Canon) on Feb 15, 2005 at 11:07 UTC | |
|
Re: Getting regular expression right
by Anonymous Monk on Feb 15, 2005 at 10:58 UTC | |
by mellin (Scribe) on Feb 15, 2005 at 12:06 UTC | |
by Anonymous Monk on Feb 15, 2005 at 12:12 UTC | |
by mellin (Scribe) on Feb 15, 2005 at 12:25 UTC | |
by Anonymous Monk on Feb 15, 2005 at 13:08 UTC | |
by mellin (Scribe) on Feb 15, 2005 at 11:03 UTC | |
|
Re: Getting regular expression right
by Animator (Hermit) on Feb 15, 2005 at 11:03 UTC |