in reply to Build your array with push
I don't like the push way of constructing arrays. I use the following idioms:
my @array = ( "Hibbs", "Daglish", "Schwartz", "Vroom", );
... which works well for adding in any place, and also (un)commenting entries. If I'm sure there are no newlines/whitespace-only elements in the array needed, I also may use the following:
my @array = grep { /\S/ } split /\n/, ' foo bar baz and so on ';
depending on how my input data gets delivered (multi-column Excel data fits better into this model for example).
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Build your array with push
by xdg (Monsignor) on Jan 31, 2006 at 15:12 UTC | |
Re^2: Build your array with push
by friedo (Prior) on Jan 31, 2006 at 20:23 UTC | |
by Roy Johnson (Monsignor) on Jan 31, 2006 at 20:26 UTC | |
by friedo (Prior) on Jan 31, 2006 at 21:31 UTC | |
Re^2: Build your array with push
by PhilHibbs (Hermit) on Jan 31, 2006 at 16:15 UTC | |
by Roy Johnson (Monsignor) on Jan 31, 2006 at 16:44 UTC | |
by integral (Hermit) on Jan 31, 2006 at 19:40 UTC | |
| |
Re^2: Build your array with push
by radiantmatrix (Parson) on Feb 01, 2006 at 16:35 UTC | |
by ikegami (Patriarch) on Feb 06, 2006 at 17:50 UTC |