Loading…
Back To Schedule
Wednesday, June 24 • 4:00pm - 4:50pm
Using Moo In Modulinos

Sign up or log in to save this to your schedule, view media, leave feedback and see who's attending!

Feedback form is now closed.
The "modulino" format allows a command line script to behave like a module that can be tested with familiar test harness tools (i.e. Test::More and Test::MockModule) without executing it, often achieving very high coverage numbers. It is only natural to bring Moo to the game.

The basic idea of a “modulino” is to take advantage of the caller() function to determine if a script is being run from the command line or being included by a require statement. This allows the code to behave as either a normal script or as a module. It is the latter behavior that enables a modulino to be fully testable without having to execute it and capture the output somehow. It allows full unit testing with tools such as Test::More and Test::MockModule.

Moo brings a well-known OO framework to the party to help organize the script more like a module and provide command line parameters as object attributes.

This talk will demonstrate with simple scripts how Moo and Getopt::Long can play nice with each other and how the modulino structure benefits testing. A Role will be introduced, MooX::Role::CliOptions, to show how coding standards can be established for standard command line options.

Speakers
avatar for Jim Bacon

Jim Bacon

Brandify
TL:DR - I am a grumpy old man who loves Perl.I first saw Perl v1 when it was first released and decided I would stick with `awk`, `sed`, `grep`, etc. Then in the mid-90s I started using Perl on a regular basis for admin work at an ISP. I have been using nothing but Perl ever since... Read More →


Wednesday June 24, 2020 4:00pm - 4:50pm EDT
Zoom Channel 1