in reply to Perl2SMS (for Vodafone Australia)
I agree that this provides a nice case study for simplifying
streamlining web interaction, but every time I see more than two levels
of indentation for nested "if (okay) ... else ..." blocks,
I wince a little. I think it would be more readable (as
Perl code, at least) if you did it this way:
... my $baseURL = "http://www1.myvodafone.com.au"; my $res; logmsg("Requesting homepage ..."); $res = $ua->request(new HTTP::Request(GET=>$baseURL)); $res->is_success or giveUp($res->status_line); logmsg("Logging in..."); $res = $ua->request(POST "$baseURL/userpages", ... ); $res->is_success or giveUp($res->status_line); logmsg("Requesting SMS form..."); $res = $ua->request(new HTTP::Request(GET=>"$baseURL/userpages/web2txt +.fcgi")); $res->is_success or giveUp($res->status_line); logmsg("Submitting SMS form..."); $res = $ua->request(POST "$baseURL/userpages/web2txt.fcgi"),...); $res->is_success or giveUp($res->status_line); logmsg("Completed submission."); sub giveUp { my $msg = shift; print scalar localtime(time) . "Error: $msg\n"; exit(1); } ...
but your newer version has nice features that many folks may appreciate more than this simple-minded approach
There may be better idioms than what I have suggested (which was equivalent to your original version), and your revised code seems to be one such idiom.
For example, you could now look at generalizing the process by reading the stateConfig data from a file -- it'll be fun figuring out how to get that to work with other args from the command line to fill in slots within the stateConfig data... Thanks for a very instructive update!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Perl2SMS (for Vodafone Australia)
by hagus (Monk) on May 26, 2002 at 13:16 UTC |