Skip to main content

Posts

Showing posts with the label Perl

Learning Perl5i #2

Continuing the exploration of Perl5i beyond  part one , I decided to treat perl5i as a language and use it to implement tasks at  Rosetta Code . Since Moose is a complete OO solution, I use a lightweight approach to OO, where used. The first RC task I implemented is 100 doors : see  the full implementation. In terms of documentation, I gave each routine a small header in which I show how the routine is invoked, specify the inputs and outputs, and summarize the primary actions of the routine. Since the task is defined in terms of a number of doors, and operations on those doors, it seemed appropriate to use an object. "some object" + "operations on that object" ==> "segregate into an OO implementation". I used a simple constructor with initialization performed in _init() to simplify subclassing. The constructor doesn't need to be modified, just a new _init() written to handle additional attributes or arguments, if any. The new implementa

Learning Perl5i

I've been looking at the module perl5i , which puts a sideways twist on Perl, eliminating tons of boring boilerplate, and introduce many conveniences. In this case, the i eliminates complexity. Installing perl5i installs a number of other modules as well, on the other hand life becomes better once they are installed. If you don't have cpanm or one of the other improved CPAN installers, the simplest way is to install perl5i and its friends using the command       sudo cpan perl5i You may need to type in yes to have cpan  install dependencies. Some modules are needed only temporarily during installation, and you are asked whether you want them permanently installed. Perl modules don't take up very much space, so I always go for it. Installation is a bit different on Windows or Linux machines, but you can figure it out, you're a mighty Perl programmer! One consideration is that major versions of perl5i may change in drastic ways. But you don't include p