|
|
| P is for Practical | |
| PerlMonks |
Re^5: Compare hash with arrays and printby almut (Canon) |
| on Jul 13, 2010 at 16:41 UTC ( [id://849315]=note: print w/replies, xml ) | Need Help?? |
|
I want to write the complete header line (starting with '>') in my output files. Can I use the split function ...? Sure you can use the split function, but if you just want to print the header line as is (i.e. copy it from the input), you wouldn't need to split up the record. As you have it, the header would be printed already without further ado. Think of it this way: $_ holds an entire record, with the leading '>' removed (to more easily handle the edge cases that result from the way the input is being split by $/). For example, for the first record, $_ would hold the string (including the newlines)
You can do with it whatever you like before you print it out, e.g. take it apart using split or via regex captures, perform regex substitutions on it, etc.
which would extract "aw1" in this case, because \w+ stops matching at the dot. In case you'd need to extract keys as "aw1.a1" (or some such — I'm no fasta expert), you could modify the regex to also capture the dots
or up until the first whitespace char in the line
Or in case you'd want to print the headers only (which I'm not quite sure from your description), you could extract it similarly with a regex
or by splitting on newlines
And so on...
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||||||||||||||