Jim Martinez wrote:
[...]
At apachecon, a speaker (who neither bragged nor rambled) mentioned lwp
use instead of (or to complement) the web browser portion.

Will the use of lwp instead of a browser improve my coding ability (either
in terms of speed or just improving my perl coding)?  Seems like I'd have
to spend too much time with the lwp script (tell it to first request the
page then choose option A and B then hit the "submit" button ... )
There are many benefits to using command line tools (which can be anything, but LWP::UserAgent and other packages in libwww-perl are a gift from god). Here are some of them off the top of my head:

1. You get the results as they come in (browsers tend to cash things).
2. You can program things:
- make a sequence of request/response cycles based on a response
- you can choose to display only certain bits of the response: e.g., show me only headers, only the body, only the size of the body, only certain keywords, etc.
3. You can easily reproduce sequences or specific inputs, especially when there is a sequence of request/response pairs to get to some state.
4. you can involve someone else in debugging the problem, without needing to come down (fly?) to his cubicle to explain how a certain anomaly is reached. So you can educate your users to create test scripts that reproduce the problem.
5. We (mod_perl programmers) very often use the single server mode (httpd -X) to test things. If you have a page with embedded images, it's going to take a while before you get the output, because you have only one server (this is documented in the guide).
6. Filling in forms.
- You can prefill forms programmatically (saving you a lot of time and protecting from mistyping things)
- You can provide inputs which with normal manual typing won't be possible (so you can test your program's behavior when a 10MB core file is submitted as a fname form's field).
... I guess there are many more things that could be added here, you get the idea.

Apache::Test is one of the new tools that work with both versions of Apache (and mod_perl and other mod_*). If you are a 3rd party mod_perl module developer (CPAN or in-house) you definitely should use it to test your module. See:
http://perl.apache.org/docs/general/testing/testing.html

The only major drawback to command line tools I can see is when you need to observe the html as is (e.g. you can't use some logic/parser to verify correctness), here the browser is definitely more useful. So knowing when to use what technique is important. Both have an application.

(I've also noticed that lwp-get sometimes have a significant delay because it tries to resolve IPs, even though the request is made to localhost. So many times I end up using just 'lynx --source')

Is there some way to improve this cycle : edit code -> refresh browser ->
possibly look at the error log -> edit code -> ...

Or maybe you use another approach that's better?
Inject mod_perl into your brain ;0)

Seriously, I don't think that the core of this cycle can be any different, other than the 'refresh browser' part.

Talking about the 'refresh browser' part. In one of the companies I've worked for, there was this girl who did some perl coding and who was very inefficient, because she didn't know she could do a refresh. Many times she needed to debug a form to which you get after a sequence of several forms, all requiring a lot of things to type in. So every time she would change a bit of code (1 sec), she would go to the first form and start filling in a form, then submit, get to the next form, fill it in, submit, and so on, till she gets to the stage she is debugging, see that her fix didn't work and start all again from scratch. On the way she would enter different data by mistake which
would lead her to the wrong stage and she would need to start from scratch again. I'm sure that you all have seen someone in your office do that. Do them and your company a favor, explain to them that you can do a refresh to resubmit just the last stage. Or even better, show them the light by pointing them to libwww-perl.

__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com

Reply via email to