Mojo Wonk Blog.

A semi-offical blog dedicated to the Mojolicious web framework

Day 2: Automatic Reload for Rapid Development

Mojolicious art and reload icon, original artwork by Doug Bell

Developing webapps with Mojolicious is a lot of fun! Using the morbo server for development, every change to my webapp causes a restart to load my changes. This way the next request I make has all my new code!

So, I change my code, the webapp restarts, and I go back to my browser window. Wait... Where's my new code? Why isn't the bug fixed? Did... Did I forget to reload my browser window again? Ugh! Of course!

Does this happen to you? Probably not. But, it's still annoying to reload the browser window after every backend code change. It'd be nice if my browser window automatically reloaded every time the web server restarted!

Continue reading Day 2: Automatic Reload for Rapid Development...

Day 23: One-Liners for Fun and Profit

Old man playing timed chess

Perl is well-known for its one-liners: short programs written as part of the command line invocation of the interpreter. Certainly every programmer or sysadmin has the need, from time to time, to do a quick one-off task programmatically. Such tasks can be done with a full script, to be sure, but once you get the hang of writing them, one-liners can save the time and hassle of actually doing so.

These tasks may include removing unwanted lines from files, collecting data from logs, or even a quick proof-of-concept of something that would become a script later. They can read lines in files, even multiple files, can operate on files in-place, can read from STDIN as a pipe. But while one-liners have been tools of the trade for these activities, certainly no such thing would be practical for web tasks, right?

But of course, on day 5 and day 6 of this series that we saw that we can build command line tools with your app. We have even seen how to use the eval command to run a one-liner against your app. So could we take this further?

Could we do remote data fetching and manipulation as a one-liner? Could we build an entire web application as a one-liner? Would I be asking if the answer was no?

Continue reading Day 23: One-Liners for Fun and Profit...