in reply to splitting every element of an array
my @segments = map [split //], @genome;
Now $segments[$i] will be a reference to an array containing the chars of $genome[$i], so you can access individual chars with $segments[$i][$j] (where $i is the segment index and $j is the part number), or the entire array of chars of one segment with @{$segments[$i]}.
For example, this code:
will output:my @genome = ("abc", "def", "ghijkl"); my @segments = map [split //], @genome; for my $seg (@segments) { print "Segment: @$seg\n"; }
Segment: a b c Segment: d e f Segment: g h i j k l
See perldoc perllol for more details.
•Update: a few corrections and a bit more explanation
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: splitting every element of an array
by MarkM (Curate) on Feb 26, 2003 at 05:55 UTC | |
by graff (Chancellor) on Feb 26, 2003 at 06:21 UTC | |
by xmath (Hermit) on Feb 26, 2003 at 08:49 UTC |