in reply to nth field extraction
which produces:-my $aref = &fieldParse($fullString, '!!', ';', ','); sub fieldParse { my $source = shift; my $ret = []; my $delim = shift; defined($delim) or return $source; for (split $delim, $source) { push @$ret, &fieldParse($_, @_); } return $ret; }
Updated (handle case of false-value delimiter as someone suggested)$VAR1 = [ [ [ 'abcd-efgh-ijkl-mnop' ], [ 'key1=data1', 'key2=data2' ], [ 'key1=data +3', 'key2=data4' ] ], [ [ 'qwer-asdf-zxcv-tyui' ], [ 'key1=data3' ], [ 'key3=data6' ] ], [ [ 'trew-hgfd-yt +re-bvcx' ], [ 'key1=data7', 'key2=data8' ], [ 'key1=data9', 'key2=data10' ] ], [ [ 'erty-dfgh-cvbn- +hjkl' ], [ 'key2=data5' ], [ 'key3=data6' ] ] ];
One world, one people
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: nth field extraction
by AnomalousMonk (Archbishop) on Jul 27, 2018 at 20:51 UTC | |
|
Re^2: nth field extraction
by lee_crites (Scribe) on Jul 27, 2018 at 14:27 UTC | |
by anonymized user 468275 (Curate) on Jul 30, 2018 at 14:37 UTC |