in reply to Re: Writing a Perl Module... problems
in thread Writing a Perl Module... problems

Your right it does work now. I'm not sure why it wasn't working before, more annoyingly I can't remember what error I was getting. I made a few changes before trying again and it works as I originally planner. How strange, there must of been something I changed. If I get the error again I'll post it here for future ref by anyone who reads this thread.
  • Comment on Re^2: Writing a Perl Module... problems

Replies are listed 'Best First'.
Re^3: Writing a Perl Module... problems
by naikonta (Curate) on Sep 15, 2007 at 16:02 UTC
    With Name::Name->subroutine() you need to capture the class name as the first argument in subroutine() method.
    package Name::Name; sub subroutine { my $class = shift; # shifting @_ print $class, "\n"; } package main; use Name::Name; Name::Name->subroutine(); # output: # Name::Name
    It's callled class method calling. With Name::Name::subroutine(), you call subroutine() with fully qualified package name without any argument.

    I'm not sure what's missing, but if the subroutine in question is new() then you can't call it Name::Name::new() as it expects the class name as its first argument. Similiar way to the class method calling above is Name::Name::new('Name::Name').


    Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!