problem creating a module in perl
Posted by: damnut
Posted on: 2006-07-08 02:45:00
So I've been playing around with creating my own module in perl. I'm having problems with passing data to subroutines inside the module. I already have some subroutines that simply return a scalar when called and those work fine. This is what I have:
I have a module called NewModule.pm. So I did this:
my $obj = new NewModule;
my $string = "hello world";
$obj->somefunction($string);
Inside NewModule.pm, I simply have this:
sub somefunction {
print $_[0];
}
Now I want it to print "hello world" to the screen, but instead I get "NewModule=HASH(0x8170d48)". What stupid mistake am I doing? Thanks.