in reply to How to clean an array of strings after a split
You could also search the pieces of interest with a single regex, and fill the array with sufficiently many empty strings like this:
my ($var1, $var2, $var3, $var4, $var5) = ( $str =~ /(?:^|\|)\s*(.*?)\s +*(?=$|\|)/g, ("")x5 );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to clean an array of strings after a split
by MrSnrub (Beadle) on Aug 29, 2013 at 14:21 UTC | |
by hdb (Monsignor) on Aug 29, 2013 at 14:37 UTC |