Moron has asked for the wisdom of the Perl Monks concerning the following question:
FA1 '|' FA2 '|' FA3 '|' FA4 [ '|' VA1 .. ]
where FAn are always-required attribute ids and VAn are zero or more optional attribute ids of no particular limit in number.
The rows thereafter are values for insert or update to the database.
The problem is that when using the split command:
(under perl version 5.6.1 if that matters) any trailing empty fields are missed from the list, i.e. a DWIM split would convert A|B|| into ['A','B', undef, undef, undef ]or I'd even be able to cope with ['A','B','','',''] but in practice perl split is returning only ['A','B'], preventing me from knowing whether the user entered A|B, A|B||| or for that matter A|B||||||||||||||||||||||||||||||||||||my ( $f1, $f2, $f3, $f4, @v ) = split( /\|/ );
I can see that tuning up the regexp is probably the way to go here, but I don't know how.
Thanks in advance.
-M
Free your mind
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: split problem when emptiness is a valid element
by inman (Curate) on Oct 04, 2005 at 16:44 UTC | |
|
Re: split problem when emptiness is a valid element
by Jenda (Abbot) on Oct 04, 2005 at 16:48 UTC | |
|
Re: split problem when emptiness is a valid element
by BrowserUk (Patriarch) on Oct 04, 2005 at 16:50 UTC | |
|
Re: split problem when emptiness is a valid element
by ikegami (Patriarch) on Oct 04, 2005 at 16:32 UTC | |
|
Re: split problem when emptiness is a valid element
by philcrow (Priest) on Oct 04, 2005 at 16:45 UTC | |
|
Re: split problem when emptiness is a valid element
by Moron (Curate) on Oct 05, 2005 at 09:14 UTC | |
|
Re: split problem when emptiness is a valid element
by blazar (Canon) on Oct 04, 2005 at 16:37 UTC |