Hello monks,
I am trying to use a small perl script where I want to connect to a webpage, download the content and print it. So far so well... the thing is, I don't want to print all the content, but only the sentences that start with a ">".
The data look like this:
>protein_name1
blablabla
>protein_name2
blablabla
>protein_name3
blablabla
Here is the code I have:
#!/usr/bin/perl
use strict;
use warnings;
use LWP::Simple;
print "Please, enter an IPR number: ";
chomp (my $IPR_numb = <STDIN>);
my $data = get("http://www.uniprot.org/uniprot/?query=database:(type:i
+nterpro+id:IPR$IPR_numb)&format=fasta");
my (@header) = $data =~ /^>(.+)/;
print "@header\n";
The problem is, I only get the first sentence starting with ">" and all the others are ignored. So in my example, I only get as output:
>protein_name1".
I would like to have instead:
>protein_name1
>protein_name2
>protein_name3
I don't understand why Perl stops after finding the first match of the regex and don't keep looking for it.
Thanks a lot for your help.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.