in reply to Can't Call method error

Your new constructor is not doing anything.
sub new { my $class = shift; my $this = {}; bless $this, $class; return $this; }
That's not the best way to go about it, but it's easy to understand if you're not used to OO programming. After making this change, your original code should work. The problem with your new constructor is that you weren't returning an object. If you printed $sm, you would have seen that you had set it's value to 1.

I should point out that blessing an empty anonymous hash isn't particularly useful. One of the nifty features of objects is to carry around a bunch of useful information with them. I only provide the above example because it's pretty clear what's going on.

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.