## Off The Moose Track

Well off track again. So I am not going to do my bit on coercion today after all. If anyone out there was actually downloading my code and running my tests you might see this;

Error=Can't locate Database/Accessor/DAD/Types.pm in @INC (@INC contains: D:\GitHub\DA-blog\lib D:\GitHub\Replay\lib C:/Dwimperl/perl/site/lib C:/Dwimperl/perl/vendor/lib C:/Dwimperl/perl/lib .) at (eval 378) line 2.

Scrolling by as the test all pass. Now this is does not bother me much as all I see here is my Accessor.pm BUILDER code rejecting the load of a non DAD class. To other this may mean that something is going wrong and I am sure, if this project every becomes successful, that I will get all sorts of questions on what is going on here. So it is always better to nip these sort of problems in the bud.

On closer inspection of the above you may notice that it is trying to load the file '/Database/Accessor/DAD/Types.pm' which is odd as there is no file of that name in that folder. The 'Types.pm' file is in the '/Database/Accessor/' folder.

So things are not going right in my system at all. At first I though it was this regex


my ($package) =$_package =~ /^([[:word:]]+(?:::[[:word:]]+)*)$/;  So I got out my old standby buddy The Regex Coach and I tested the expression and it came out all right so it wasn't that one. So onto the the next one then; $dir =~ s/^.+Database\/Accessor\///;


and a quick warn on the next line showed me

Then that little light clicked on in my brain and I remembered that I am on a windows box so my '\/' part in my regex is not going to work as it would on a Linux box where I had orginally used this code, there it would be

I have a few options none of them very elegant, there is most likely a regex out there that will work for both Windows and Linux but I have yet to find one and my regex skills are mediocre at best So I think I will do the brute force approach and just swap out the '\' for '/'. In the end this small change will make my Accessor more portable across OSes and I do not think I will have any problems as Windows doesn't care really between the two, 'dir /foo/bar' and 'dir \bar\for' and on Linux nothing will change.

Oh by the way I also noticed that I was missing the DAD part on the end of that regex, if you remember in my name-space statement from a few posts ago I want all DADs under that name-space , so in the end this is what I came up with;


$dir =~ s/\\/\//gi;$dir =~ s/^.+Database\/Accessor\/DAD\///;
warn("dir=$dir");  which gives me dir= and that is what I want. The code that follows is designed to find DADs that are deeper in the name-space than the DAD level. So a path like this '/GitHub/DA-blog/lib/Database/Accessor/DAD/NoSQL/Dimingo,pm would give me the correct class name later on. Now I also noticed that in my BUILD I also forgot to put the 'DAD' in there so with that change  --grep { -d$_ } map { File::Spec->catdir($_, 'Database','Accessor','DAD' ) } @INC; ++grep { -d$_ } map { File::Spec->catdir($_, 'Database','Accessor' ) } @INC;  and this other typo I missed.  --$classname = join '::', 'DA_SC', 'LSD', $package,$file;
++$classname = join '::', 'Database', 'Accessor', 'DAD',$package, \$file;