[ale] More perl than linux related question

Fletch fletch at phydeaux.org
Mon Jun 18 21:54:19 EDT 2001


>>>>> "James" == James CE Johnson <jcej at tragus.org> writes:


[...]

    James> The answer to your specific question is taken care of in
    James> three lines:

    James>  local $ua = LWP::UserAgent->new; 
    James>  my $request = HTTP::Request->new('GET',"somePage");
    James>  my $response = $ua->request($request,"localCopyOfSomePage");


        I can do it in two lines (even counting the use line you
ommitted to get yours down to three :) . . .


use LWP::Simple qw( mirror );
mirror( "http://www.somewhere.com/foo.html", "foo.html" );


        Golf aside, if all you need to do is just mirror a page then
LWP::Simple will probably do (hence the name).  If you need something
fancier (say you want to fake Referrer: headers, or you need to
provide a username and password), then you'll need LWP::UserAgent.


        For more information on LWP, type `perldoc lwpcook' at your
prompt.  You also might want to look at the source for the LWP utility
`lwp-mirror' that comes with LWP (more `which lwp-mirror`).


-- 
Fletch                | "If you find my answers frightening,       __`'/|
fletch at phydeaux.org   |  Vincent, you should cease askin'          \ o.O'
770 933-0600 x211(w)  |  scary questions." -- Jules                =(___)=
                      |                                               U
--
To unsubscribe: mail majordomo at ale.org with "unsubscribe ale" in message body.





More information about the Ale mailing list