### Re^4: Creating 2 arrays from a larger array

by imtakinbioinformatic (Initiate)
 on Mar 08, 2012 at 04:08 UTC ( #958423=note: print w/replies, xml ) Need Help??

in reply to Re^3: Creating 2 arrays from a larger array
in thread Creating 2 arrays from a larger array

uggg still not getting it. No errors but the elements I printed were all the same. I'll keep working, thanks for explaining!
• Comment on Re^4: Creating 2 arrays from a larger array

Replies are listed 'Best First'.
Re^5: Creating 2 arrays from a larger array
by NetWallah (Canon) on Mar 08, 2012 at 06:15 UTC
A HASH makes more sense for this structure:
```my (\$k,\$v, %seq);
for my \$line (<DATA>) {
chomp (\$line);
if ( \$line=~/^>(\S+)\s*(.*)/){
\$k=\$1;
\$v=\$2;
}else{
\$v=\$line;
}
\$seq{\$k} .= \$v;
}
#---- Print it ----
for my \$k(sort keys %seq){
print "\$k \t=> \$seq{\$k}\n";
}
# --- Output ---(Using the __DATA__ block above) ..-
#  123     => blahabcdefghijkl
#  456     => de dahmnopqr
#  789     => nothing wanted herestuvwxyz

All great truths begin as blasphemies.
― George Bernard Shaw, writer, Nobel laureate (1856-1950)

Re^5: Creating 2 arrays from a larger array
by tangent (Priest) on Mar 08, 2012 at 13:54 UTC
but the elements I printed were all the same
Can you post some sample data?
Re^5: Creating 2 arrays from a larger array
by imtakinbioinformatic (Initiate) on Mar 08, 2012 at 14:59 UTC
Oh it works! It seemed important that the variables were my variables? Thank you soooo much!!

Create A New User
Node Status?
node history
Node Type: note [id://958423]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2018-03-24 10:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
When I think of a mole I think of:

Results (298 votes). Check out past polls.

Notices?