> [Eric would] use Ruby, personally.  It'd be much more readable than
the  
> equivalent Perl variant, almost for sure.  The readability factors  
> into the maintainability too.

Let me break that down a bit...

Can we assume you, Eric, have the experience to write either a perl or
ruby script?

So the choice of Ruby was because you believe that would be more
readable than a perl equivalent, not due... maybe because of more
familiarity with Ruby and less with Perl?

I'm trying to put that gingerly...because, well, my equivelant of your
script looks "readable" to me, because I know more Perl than Ruby. :-)


-Timo
----
# Leverage the LWP Useragent lib 
# http://search.cpan.org/~gaas/libwww-perl-5.803/lib/LWP/UserAgent.pm

 require LWP::UserAgent;
  
 my $ua = LWP::UserAgent->new;

 # agent automagically handles 7 redirects by default, but we'll
increase to 10
 $ua->max_redirect(10) 

 my $url = "http://www.somewhere.com/logs/logfile.txt";;

 my $response = $ua->get($url);
 
 if ($response->is_success) {
     print $response->content;  
 }
 else {
     die $response->status_line;
 }


> One way would be to leverage the Net::HTTP library:
>      <http://www.ruby-doc.org/stdlib/libdoc/net/http/rdoc/>
> 
> I use it to fetch a string from an HTTP response this way:
> 
>       # Fetch method copied from PickAxe, p. 700
>      def fetch(uri_str, limit=10)
>         fail 'http redirect too deep' if limit.zero?
> 
>         response = Net::HTTP.get_response(URI.parse(uri_str))
> 
>         case response
>            when Net::HTTPSuccess
>               response
>            when Net::HTTPRedirection
>               fetch(response['location'], limit - 1)
>            else
>               response.error!
>         end
>      end
> 
> fetch("http://www.ruby-lang.org";) # for example, which would follow  
> the redirect to /en
> 
> To pull binary content, you'll have to use the API slightly  
> differently, but it'll still be pretty trivial.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to