eric256 has asked for the wisdom of the Perl Monks concerning the following question:

So I want to optomize our company website to at least follow the general recommendations for making sites search engine friendly. I don't want to try and stuff it full of keywords or anything, just test to see what changes should be made to my design in order to make it better. So I started with a base modules SEO::Tests (no the names are not good or permanent, just have to start somewhere) which has plugins in the SEO::Tests::* name space. It uses Module::Pluggable to find, load and enumerate plugins. Each plugin then has three methods, prepare, describe, run_tests. My problem starts here with the tests. I want each name space to be able to have numerous tests it can run and all tests return their status in a defined mannor so that the main program can choose to display how to print out the results. I also want each test to be able to return all score meanings, so that someone can tell if it scored a 5 and it was only 'ok' how close they were to getting a 'good'. Well in the interest of trying to keep it short i'll just post the plugin code here ( and i can provide the full code if it turns out to be needed.) This first plugin runs two tests, one on the length of the title and the other on the keyword density of the title.

package SEO::Tests::Head; use strict; package SEO::Tests::Title; sub prepare { my ($class, $self) = @_; $self->info->{title}->{content} = $self->gather_tag( 'title', {} , sub { $_->as_trimmed_ +text() }); $self->process_keywords($self->info->{title}, 'content'); }; sub describe { "Check Title for length and keywords" }; sub run_tests { my ($class, $self) = @_; return [ { name => 'Title Length', score => length( $self->info->{title}->{content}), meanings => [ [0 , 1, 'bad', 'No Description'], [ 1, 20, 'ok', 'Too short'], [20, 70, 'good', 'Just Right'], [70, 9999, 'bad', 'Too long'], ], }, { name => 'Title Keywords Ratio', score => $self->info->{title}->{keywords}->{ratio}, meanings => [ [0 , 0.25, 'ok', 'Too short'], [.25 , 0.50, 'good', 'Just Right'], [0.50, 9999, 'bad', 'Too many'], ], }, ]; }

You can see that currently this structure results in a layer of nested array refs and hash refs. Does anyone see a clearer way to do this? Perhaps registering each test inside the the plugins. I almost want to do plugins inside the plugins, but that realy seems insane. So in short: I want a way for the plugin to register multiple tests and have each of those tests called individualy where they will return the name, the score and a meaning matrix so that different output methods can be used on the same data. If I havn't confused everyone with this i will be overjoyed! lol.


___________
Eric Hodges