in reply to Use of Handle to use subroutines in a module

Your syntax is wrong on the first example. It's not a => operator, it's my $handle = TeamSite::Config->new();

And that is one of the most common ways to instantiate an object using Perl's object system. The second example you gave, File::Copy, is not an object oriented module. Instead, it internally invokes the Exporter module to export the copy() subroutine into your main package namespace so that you can invoke it almost as if it were a built-in function.

So the first is an example of an Object Oriented module, and the second is a Module with a functional interface.

I would say to pick up a copy of Intermediate Perl, published by O'Reilly. It covers modules, and an introduction to Object Oriented programming. But it may be too big a bite to chew on if you're really new to Perl. If that's the case, start with Learning Perl (the Llama book), and then move on to Intermediate Perl.

There is also perlmod, and perltoot; Perl documentation that is free and explains modules and OO programming with Perl.


Dave

Replies are listed 'Best First'.
Re^2: Use of Handle to use subroutines in a module
by manishrathi (Beadle) on Aug 08, 2011 at 08:01 UTC
    How do I know which module is Object Oriented Perl module and which one is not ?

      You type: perldoc Module::Name, and look at the SYNOPSIS section in the documentation. If you see an object being instantiated it's an OO module. If you see bare functions being used, it's not OO.... unless you have one of those modules that does both, such as CGI. For those, you'll have to actually read a little further in the documentation.


      Dave