Looking for Moose in all the Wrong Places

In my last post I again ending up like poor Keith Haring in his picture below.

13-Ptgintocorner04.jpg

I programmed what I wanted but it was beginning to look like the same stuff I started with.

So playing around a bit I remembered that Moose has the before, after and around Method Modifiers that work like DBI's callbacks that some of you might remember form one of my earlier posts. The great thing about these is that can be used from inside a role for code outside the role as long as the code is referenced in a 'requires'.

So I to move the max values out of the Character class and into the Dwarf role I gave this a shot

Change Counting Problem - Feedback Requested

There's a common programming challenge where you write a program to take a dollar amount from the user, and then return the simplest way to create that amount with only coins (using the fewest coins possible). I took a crack at this a while back, and I would like to know if there are ways it could be improved or if you would have done it differently.

Resolving non-perl dependencies for perl modules in Debian/Ubuntu

One of the things developers often struggle with is dependency resolution.

For example:
cpanm WWW::Curl::Easy -v

.....

Configuring WWW-Curl-4.15 ... Locating required external dependency bin:curl-config... missing.

Unresolvable missing external dependency.

Please install 'curl-config' seperately and try again.

NA: Unable to build distribution on this platform.

A framework for Alien modules (the Alien2 Manifesto)

The purpose of Alien modules is to provide external libraries or other dependencies for CPAN packages. This Alien2 Manifesto updates the original Alien module description based on practical lessons from existing Alien module implementations and some perceived limitations.

The original Alien manifesto provided the idea but not a framework for how modules in the Alien namespace were to work. The plan was to "let evolution work for us and see what individual Alien packages need and then eventually factor it out". We are now more than 10 years after this first proposal and there are now some lessons to be learned from current implementations of Alien modules. Let's start with a review of the responsibilities of an Alien module and some observations.

On installation, make sure the required package is there, otherwise install it.

This is the main purpose of Alien modules, to provided external library or program dependencies needed for CPAN modules installation and operation.

Thou yeasty elf-skinned baggage!

With my last post I managed to apply a role to an instance of a class. What I think this will allow me to do is keep my base 'classes' from sprawling out of control while also encapsulation a good number of Game Rules' (or Biz Rules) in to small parts that I can easily reuse.

So far it has handled things quite well and even taught me a few things and I think has really exposed what Roles can do in Moose. Now as my D&D story moves along I am about to jump into what I think is going to be the to big test for Moose.

Character Races??

The differing races bring a new level of complexity to the game, well except mundane old humans who, unlike the other races, get no extra abilities, bonuses, penalties or alike.

Perl and Me, Part 4: A Worthy Program, Exceedingly Well Read

This is part 4 of an ongoing series where I explore my relationship with Perl.  You may wish to begin at the beginning.

This week we look at code legibility.

Last week I talked about why Moose is important to my journey as a Perl programmer, and where I feel that it could be even better.  I concluded that it all comes back to code legibility. 

Perl Reverse Dictionary/Array

I have translated "Perl Reverse Dictionary/Array".

Perl Reverse Dictionary/Array

Graphics::Potrace

A few months ago I released Graphics::Potrace, that provides Perl bindings to the potrace library. So, if you want to convert rasters into vectors from Perl... you know where to go.

Once more unto the breach, dear friends, once more;

In my last D&D post I managed to get my generic 'OpenDoorsOnA' role working with my 'Fighter' class but I was left wondering if I would make better sense to make 'Exceptional' Strength a role then only use it the rare time that a 'Fighter' character has 18 strength????

146e5bd2de81a98608834843fc9d5b1b_large.jpg

Whenever I see the phrase 'conditionally loads the needed class' in the spec documentation it sends shivers down my spine. Then again anyone who as used DBI has used conditional loading of classes but most times I see silly shortcuts like this

Merry Christmas! Parallel testing with Test::Class::Moose has arrived

You'll want to checkout the forks branch to see it in action. Read the docs for Test::Class::Moose::Role::Parallel to see how to use it (you'll probably need to create your own schedule).

What follows is a very naïve benchmark where I reduced a 12 minute test suite down to 30 seconds.

JAGC -- Just Another Golf Coding

JAGC is a server for code golf, where users write the shortest code using all standard features of scripting languages for solve tasks.
Users can add new tasks with unit tests, invent solutions and submit them.
JAGC will run tests for these solutions to determine the winner.

We will be glad to see your feedback.

Visit about page for more information.

Pjam - continues integration for PERL, using pinto.

Pinto is an application for creating and managing a custom CPAN-like repository of Perl modules. Pjam is a tool which enables automatic creation of perl applications distribution archives from source code using pinto. Pjam enables continues integration in PERL. Right now pjam fits only Module:Build based projects ( Build.PL should be provided ) kept under subversion SCM, but I may change this if interest will be shown.

Pjam can be used in two ways - as command line utility and via web api to take some actions remotely.

Checkout https://github.com/melezhik/jam for detailed info.

To Extend, or Not to Extend: That is the Question:

With apologies to The Bard and The Scottish Play for the bad miss-quote above. I am continuing on with my D&D Moose Quest. The last post I left of with what to do now that I am going to try to use a number of Mixins and how they perhaps can work with other classes.

I have chosen the 'OpenDoorsOnA' character ability as it is one that is not only effected by 'Strength' it can also be effected by The 'Fighter Class' as they get an extra roll of % dice to extend there strength from 01 to 100 (00 in D&D speak) but still staying below 19. To account for this I could just fix my 'OpenDoorsOnA' role a little to look for the exceptional strength attribute like this

Accidentally duplicating tests with Test::Class

Imagine you open up a test file and you see the following:

is foobar(3), 17, 'foobar(3) should return 17';
is foobar(2), 15, 'foobar(2) should return 15';
is foobar(3), 17, 'foobar(3) should return 17';   # duplicate?
is foobar(4), 20, 'foobar(4) should return 20';
is foobar(3), 17, 'foobar(3) should return 17';   # duplicate?

Well, that looks strange and duplicated tests are a code smell. However, it could be a code smell in one of two ways. It's probably the case that some programmer got sloppy and duplicated the tests so do you delete the extra tests?

A tour on perl-5.18.1 with c2ast, Marpa-powered C parser

The section on reserved names in GCC documentation gives several recommendations that probably the vast majority of C programs in the world do not follow.

Nevertheless, these are all good practices, and an interesting exercice was to check how the latest stable perl source code behaves v.s. these recommendations. As of the day writing this blog entry, this is perl-5.18.1.

The analysis has been done using c2ast.pl tool, from MarpaX::Languages::C::AST package, a Marpa::R2 powered C parser, advertised previously in this blogs.perl.org entry by Jeffrey Kegler.

Detailed list of "violations" is at this gist, generated on linux and gcc version 4.8.2 (Debian 4.8.2-10). It is interesting to note that over 1316 hits, there are 8 categories, with 4 of them eating 98% of the hits:

Keeping up to date.

Here is one way

 
      perl -nE '
            /=head2.*L<([^|]+)/ and $s{$1}++;
           END{ say for (keys %s)}' `perldoc -l perllocal` | 
      while read f; do cpanm $f; done

What are some others?

Roasted Moose With all the Mixins

In my last D&D post I left off with my six abilities as attributes in my character class and two 'traits/roles', ('Languages' and 'Henchmen') it did leave me with the question. Should I treat all or just some these character abilities as 'trait/roles' or should some be subs in my base class or $flip back and make my base abilities roles or even to go back to square one again and just make them subs in my original base class??

So I did a little reading and thinking and personally all these little code snippets do make my base class a little less cluttered which is nice but doesn't give me much. So I was wondering if I could reuse any of them and perhaps benefit from code reuse.

Christmas Eve Obfu

use v5.14;
use strict;
use warnings FATAL => 'all';

our $days_until_christmas = 1

            *
           map
          s([+]
         )( )gix
        &&printf(
          '%5s'
         .'%-4s'
        .'%s',$_,
       substr(~~~~
      reverse,!$^C)
         =~y[/(]
        [\\)]r,$/
       ),my@ xmas=
      qw 1 +.- _(+"
     (_++: /+' +(_/^
           1;1
           ;1;

How can I make this Perl code run faster ?

Hello world and Happy Holidays!! This is my first time blogging in blogs.perl.org and I figure I take this opportunity to ask the Perl community for suggestions on how I can make this Perl code run faster.

https://github.com/itcharlie/IDP_charlie/blob/master/perl_tools/bundle2pinto.pl

As the name of the script implies, I want to parse a cpan autobundle file so I can generate a list of distribution files from which I can create a Pinto repository. Please note that the script is incomplete and I am just wondering if there is a better approach to generate a list of distribution files.

A sample of an autobundle file can be found in the link below:

https://github.com/itcharlie/IDP_charlie/blob/master/perl_tools/Snapshot_2013_12_17_00.pm

Please note that the way to run this program is by passing the autobundle filename as an argument like so:

./bundle2pinto.pl Snapshot_2013_12_17_00.pm

Below is a copy of the code:

table_watch_SQLite

Hello, I'd like to post a link to the "table_watch_SQLite.pl" script. It's not a link in the strict sense because I couldn't manage to set a MetaCPAN perma-link to a single file.
The script is located in the "example" directory of the Term::Choose distro.
With "table_watch_SQLite.pl" one can search and read in Databases.
I use it for SQLite Databases but it should work with MySQL and PostgreSQL Databases too.

About blogs.perl.org

blogs.perl.org is a common blogging platform for the Perl community. Written in Perl with a graphic design donated by Six Apart, Ltd.