Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

when i access a url on my server, i actually read a xml file. The URL on my server is as follows http://192.168.4.1:9595/a/b/info The info is a xml file, which is not physically present on the hard disk ( i think this xml is created only when i access this url). Now i want a copy of this xml physically on my harddisk ( say c:\info.xml), so that i can download this xml file. Physically i can go to the url and click on "Save as" and save the file. But i have more than 30 files to be saved. How to do this in perl ? How do i save a URL on my server which displays a XML file to a XML file ?

Replies are listed 'Best First'.
Re: how to save a url as a XML file
by davorg (Chancellor) on Jul 27, 2006 at 11:45 UTC

    Use the getstore function from LWP::Simple.

    --
    <http://dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

Re: how to save a url as a XML file
by gellyfish (Monsignor) on Jul 27, 2006 at 11:45 UTC

    You will need to use LWP:

    use strict; use LWP::Simple; my $doc = get 'http://192.168.4.1:9595/a/b/info'; open OUT,'>info.xml' or die "can't open info.xml - $!\n"; print OUT $doc; close OUT;

    /J\