A new Mojolicious plugin has been released, Mojolicious::Plugin::ConsoleLogger.
By default, Mojolicious will send debug messages to a log/[mode].log file; if the log directory does not exist, messages will default to the terminal console.
You can use any of the four logging groups for customized messages:
Now that we've seen how easy Mojo::DOM makes parsing html, let's take a closer look at the css selector goodness it provides.
Here's a fairly verbose html sample for us to work with:
First, we initialize and parse the file:
use File::Slurp 'slurp';
my $dom = Mojo::DOM->new->parse(scalar slurp 'some.html');
Getting all the articles' contents, of course, is easy:
They say programmers don't like to test.
It seems to me that the folks who say that aren't programmers. If they are, they've never been the sole responsible party for any application. When there's no one to pass the blame to, TDD is no longer just an idea, it's time & money.
Once you get the hang of it, the peace of knowing that your code works has a value beyond measurement.
It's for this reason Mojolicious makes it easy to test your web apps in a clean, simple manner.
Long ago, I used regex's to parse HTML.
They told me it was evil. They told me it was not maintainable. They were right.
HTML::Parser, HTML::TreeBuilder, I'm sure you're brilliant in your own way. I'm sure you have conquered many lands, and for those who wanted to adapt to your mindset, you brought much happiness…