the
->get
will return immediately since it doesn't block when using the LWP::Protocol::AnyEvent::http module.
That's not true. It blocks as normal. LWP::Protocol::AnyEvent::http should not affect how WWW::Mechanize works at all. It merely allows other Coro threads and AnyEvent callbacks to execute while WWW::Mechanize is blocked.
How do I make sure the
->get
has succeeded before going into the foreach loop?
Your code already waits for it to complete. (In fact, I'm tempted to add your code to the documentation!)
If you want to check if it succeeded, you could use
die "Error" if !$mech->success;