Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Hello, I'm trying to work on code that reads an input file that has lines that start with > then lines of characters (repeated many times). I want to put the line that starts with > into one array, and then put all of the lines following the >line into a separate array as one element (until the next > comes.) So I want to end up with one array that has all of those > lines as elements, and then another array that has all of the text behind each of those > lines as separate elements. My code is working for the > lines how I want, but I seem to just be filling the second array with the text that followed that first >. I feel like this is confusing, but any help would be greatly appreciated!

foreach $line(@DNA){ if ($line=~/^>(\S+)/){ $seqID=$1; push(@seqList, $seqID); push (@sequences,$dnaString); } else{ chomp $line; $dnaString=$dnaString .$line;} }

In reply to Creating 2 arrays from a larger array by imtakinbioinformatic

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-19 23:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found