-NB- before I start I must mention I'm an OO virgin so please take it slow.
I wrote this small module for a project I'm working on. It's supposed to build an array_ref [] into which I can add many instances of a hash_ref { code, index_value ) from this I would like to be able to sort the array via the index value and when the time comes print the whole list of 'code' in order.
I think I have achieved this minus safeguards etc. (check code below) but... when I add iXML::TheConstruct->new(); to my application it tells me that it "cant locate object method 'new' via package iXML::TheConstruct". I have used 'use lib "/dir/to/project"' and I have use iXML::TheConstruct; and the .pm is iXML/TheConstruct.pm and seems to be found ok.
Is it something to do with the way I have constructed my module, etc? I have look/searched everywhere including past nodes here but I cannot find an answer.
<sidenote> I'm also using Apache::Request, could that be having any adverse effects (I know it does with variables "not remaining shared")</sidenote>
iXML/TheConstruct.pm ->
#!/usr/bin/perl -w
package iXML::TheConstuct;
$VERSION = 0.01;
use strict;
sub new {
my $proto = shift;
my $class = ref($proto) || $proto;
my $self = [];
bless($self, $class);
return $class;
}
sub add {
my ($_self, $_obj_html, $_ind) = @_;
my $_obj_hash = { OBJ_HTML => $_obj_html, OBJ_IND => $_ind};
push @{$_self}, $_obj_hash;
# sort array according to hash OBJ_IND :)
}
sub output {
my ($_self) = @_;
my $_html_data;
foreach my $_obj ( @{$_self} ) {
$_html_data .= $_obj->{'OBJ_HTML'};
};
return $_html_data;
}
1;