[tpm] Problem with WWW::Mechanize in Dancer
J. Bobby Lopez
jbl at jbldata.com
Fri Apr 8 10:57:04 PDT 2011
In this instance, I was just playing around to see if I could make the RPC
call to itself. Using subs as Flavio suggested (on the Dancer list) removes
the need to make the RPC call, but it would have been neat to write the UI
components using the API as it was intended, even if it was within the same
The guys on the Dancer list were saying this isn't how it should be used
(Dancer RPC calls should not be made to itself, and that this is what's
causing the hang).
I removed a bunch of debug statements to make the code easier to read (on
pastebin), but I I had some code in there to check the browser->get()
Never used Try::Tiny, so will have to take a look at that; and I've used
Mechanize a few times before so it just seemed natural, but I'll look at
LWP::UserAgent as well.
I know better about shifting off @_, but old habits die hard :\
Thanks very much for the feedback and suggestions, very much appreciated.
On Fri, Apr 8, 2011 at 11:45 AM, Alex Beamish <talexb at gmail.com> wrote:
> Hi Bobby,
> Some stylistic comments ..
>  I always cringe when I see shift used to take stuff off the
> parameter list .. even if it's for a single argument, I prefer .. my (
> $url ) = @_ ..
>  WWW::Mech is a great module, but I'm not sure why you need to use
> it, rather than LWP::UserAgent, which it inherits. Simple is better --
> but I have no idea if that would solve the hanging problem.
>  After calling WWW::Mech, you're not testing whether you got a good
> browser object back .. might be good to check that.
>  Try::Tiny is a nice alternative to eval .. just be aware if you use
> that module that the error ends up in $_, not $@.
> I assume you're not able to look at the web server where your request
> is going .. but if you are, the server logs might give you some
> Good luck!
> Alex Beamish
> Toronto, Ontario
> aka talexb
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the toronto-pm