Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Feb 2011
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question Downloading a XML file on my disk (Perl!)

    Stupid question (posted here because this is probably more a question about perl than about XML).

    I am coding a webtool in Perl. At one point in the code, I want to retrieve the xml file at:
    http://pfam.sanger.ac.uk/search/sequ...fbb?output=xml
    (it will probably be empty when you read this because this is a prediction webservice which erases the xml output after some time)

    To do it, I wrote:


    use LWP::Simple;

    my $status = get("http://pfam.sanger.ac.uk/search/sequence/resultset/adabec68-703f-48c4-bec7-07f1ab965fbb?output=xml");

    print $status;

    But I cannot see anything. The site I want to get the XML from uses cgi I suppose, and the problem might come from here.

    thanks in advance if you can give me some help.
    Last edited by mrdvd030; 02-23-2011 at 07:22 PM.

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by mrdvd030 View Post
    Stupid question (posted here because this is probably more a question about perl than about XML).

    I am coding a webtool in Perl. At one point in the code, I want to retrieve the xml file at:
    http://pfam.sanger.ac.uk/search/sequ...fbb?output=xml
    (it will probably be empty when you read this because this is a prediction webservice which erases the xml output after some time)

    To do it, I wrote:


    use LWP::Simple;

    my $status = get("http://pfam.sanger.ac.uk/search/sequence/resultset/adabec68-703f-48c4-bec7-07f1ab965fbb?output=xml");

    print $status;

    But I cannot see anything. The site I want to get the XML from uses cgi I suppose, and the problem might come from here.

    thanks in advance if you can give me some help.
    Code:
    use LWP::Simple;
    
    my $status = get("http://pfam.sanger.ac.uk/search/sequence/resultset/adabec68-703f-48c4-bec7-07f1ab965fbb?output=xml"); 
    
    use Data::Dumper;
    print Dumper($status);
    
    # or
    if($status->is_success){
       print $status->content;
    }else{
       print $status->status_line;
    }
    see perldoc lwp::useragent

    Edit: is a good habit on this forum to remember posters to use strict and warnings pragma in their scripts. I don't know if you use it or not but just in case,

    best regards
    Last edited by oesxyl; 02-23-2011 at 07:32 PM.

  • Users who have thanked oesxyl for this post:

    mrdvd030 (02-23-2011)

  • #3
    New to the CF scene
    Join Date
    Feb 2011
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Cool

    Beautiful.
    Actually I tried this and it worked:

    my $browser = LWP::UserAgent->new;

    $browser->get('http://pfam.sanger.ac.uk/search/sequence/resultset/adabec68-703f-48c4-bec7-07f1ab965fbb', ':content_file' => "test" , );

    And the code wonderfully printed the code in the test file on my disk.

    Thanks a lot dear oesxyl (interesting name, I would probably have a hard time to pronounce it, but please accept my apologizes). And yes, I use strict and warnings but I did not want to copy to much information. My code is already long...

    Cheers,

    dvd

  • #4
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by mrdvd030 View Post
    Beautiful.
    Actually I tried this and it worked:

    my $browser = LWP::UserAgent->new;

    $browser->get('http://pfam.sanger.ac.uk/search/sequence/resultset/adabec68-703f-48c4-bec7-07f1ab965fbb', ':content_file' => "test" , );

    And the code wonderfully printed the code in the test file on my disk.

    Thanks a lot dear oesxyl (interesting name, I would probably have a hard time to pronounce it, but please accept my apologizes). And yes, I use strict and warnings but I did not want to copy to much information. My code is already long...

    Cheers,

    dvd
    you are welcome,

    don't try to pronounce it,
    Code:
    print join '', reverse split //, "oesxyl";
    best regards

  • #5
    New Coder
    Join Date
    Oct 2006
    Posts
    68
    Thanks
    0
    Thanked 28 Times in 28 Posts
    Quote Originally Posted by oesxyl View Post
    Code:
    print join '', reverse split //, "oesxyl";
    Or
    Code:
    print scalar reverse "oesxyl";

  • Users who have thanked miller for this post:

    oesxyl (02-24-2011)

  • #6
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by miller View Post
    Or
    Code:
    print scalar reverse "oesxyl";
    yes, but is not so funcy,

    best regards


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •