Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re^5: Creating 2 arrays from a larger array

by NetWallah (Abbot)
on Mar 08, 2012 at 06:15 UTC ( #958434=note: print w/replies, xml ) Need Help??

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

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)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://958434]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2017-06-28 20:07 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (646 votes). Check out past polls.