Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Update: The code is very different now compared to when I first wrote this reply, so I'll just keep the parts that I think might still be relevant (and ++ the current version!)</update>

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!


In reply to Re: Perl2SMS (for Vodafone Australia) by graff
in thread Perl2SMS (for Vodafone Australia) by hagus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (2)
As of 2024-04-26 03:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found