Little Bugs

Sometimes littlest bugs can really get on your nerves

25541-004-01C5DA95.jpg

Though not as much as the little critter above.

All started with a little module I wanted to upload to CPAN, well I did all the right things, test suite, manifest, makefile, POD coverage etc. I just wanted to do one test install on a clean box so I used my own Windblows PC.

Well it unzipped fine, passed its tests and installed with no problems. Great let see if it works



d:\test perl somethingfromnothing.pl
d:\test Use of uninitialized value $template in split at /usr/local/share/perl/5.18.2/Mojo/Template.pm line 151, line 2231.
[exist] d:\test
[write] d:\test\RoutesRestfulCode
d:\test Use of uninitialized value $template in split at /usr/local/share/perl/5.18.2/Mojo/Template.pm line 151, line 2231.

Aggh what is the above, this worked fine on Linux??

I must of buggered up my templates somehow but they are only a few lines



__DATA__

@@ just_code
% my $routes = shift;

% foreach my $route (@{$routes}){
$r->route("<%=$route->{url}%>")->via(<%=$route->{methods}%>)->to( "<%=$route->{controller}%>", <%=$route->{stash}%>);
% }

Well there must be something wrong with my Mojo, it is a little older and I haven't used it for a year or so.

So remove and reinstall Mojolicous and the same result??

Bahh!! What is going on??

Well after hacking into Mojolicoius and adding a good number of warns with good old caller



my ($package, $filename, $line) = caller;
warn ( "package=$package, filename=$filename, line=$line" );


to back trace my problem I ended up just wasting a good hour and a half!!

Well then I noticed that I had not installed;

  • Lingua::EN::Inflect

Of course that is it. I dutifully installed it and fixed the problem with the Makefile.PL by adding in



"PREREQ_PM" => {
"Mojo::Base" => 0
++ "Lingua::EN::Inflect"=>1,
},


and then tried it again.

Well of course it didn't work! Same error as before but at least I found and fixed one bug.

Well next I spent an hour or two trying to google the error with so many incantations of



Use of uninitialized value $template in split at /usr/local/share/perl/5.18.2/Mojo/Template.pm line 151, line 2231.


that I must be driving the web crawlers and indexing servers at google nuts as at least 20 times I got no results with must set off about 70k+ flags in the back end of Google that they must be missing something out there to assimilate

Borgle.jpg

with no useful result.

Well eventually went back to my Linux box and and sure enough it was broken there as well. Then it was rather simple matter to back out all my resent changes and found that it worked if I got rid of all my POD which to me was really odd.

So it must be some problem with my POD and I deleted it line by line, and as this day was going bad anyway, I started at the last line rather than the first and when I eventually deleted the first line of my POD



__END__


and presto it worked.

So add in my POD again less the __END__ token and all was good.

But Why??

It seems the __END__ token does just that "END THE PROGRAM". So my __Data__ section, where my templates where, was never seen by my other code and thus the rather odd Mojo message which makes sense now.

A little more reading I did discover that it is possible to use both of these tokens but I did not want to get into the rather obtuse FOOBAR::DATA so the simple solution was to drop the __END__ token.

Now to release that code.


Leave a comment

About byterock

user-pic Long time Perl guy, a few CPAN mods allot of work on DBD::Oracle and a few YAPC presentations