coldy has asked for the wisdom of the Perl Monks concerning the following question:
The data looks something like
I read the file line by line (skipping the comment char) into an array,> comment 10 12 18 20 21 25 27 38 40 41 43 50
Id like each record in the file (excluding comment characters or newline characters) as an array element, so for my example data it would look likewhile ( <INFILE> ) { next if ($_ =~ /^(\>)/); push @dat, $_; }
Is there a fast way to split array elements, other than what Ive done below?@arr = (10, 12, 18, 20,21, 25, 27, 38,40, 41, 43, 50)
Thanks.my @arr; foreach (@dat) { my @a = split(//,$_); @arr = (@arr, @a); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: split array elements
by roubi (Hermit) on Apr 17, 2009 at 03:09 UTC | |
|
Re: split array elements
by jwkrahn (Abbot) on Apr 17, 2009 at 05:37 UTC | |
|
Re: split array elements
by targetsmart (Curate) on Apr 17, 2009 at 09:33 UTC | |
|
Re: split array elements
by GrandFather (Saint) on Apr 17, 2009 at 03:33 UTC |