in reply to How to handle a variable number of results from split()?
I'm also assuming that you meant that each line of your input file had a different number of "dash pairs" such as:
--- beginning of data --- 1-2,3-4,2-5 2-1,2-5 3-5,1-9,2-2,4-8 --- end of data --- use warnings; use strict; while (<>) { chomp; my @dashpairs = split(/,/); foreach my $dashpair (@dashpairs) { my ($num1, $num2) = split(/-/,$dashpair); print "$num1 - $num2\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to handle a variable number of results from split()?
by Transient (Hermit) on Jul 20, 2005 at 17:17 UTC | |
by jdporter (Paladin) on Jul 20, 2005 at 18:43 UTC | |
|
Re^2: How to handle a variable number of results from split()?
by Anonymous Monk on Jul 21, 2005 at 08:20 UTC |