Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Module vs Singleton

by Anonymous Monk
on Jul 15, 2011 at 17:10 UTC ( [id://914659]=note: print w/replies, xml ) Need Help??


in reply to Module vs Singleton

Tutorials: Modules: How to Create, Install, and Use: Creating and Distributing Modules: Simple Module Tutorial

http://learn.perl.org/books/beginning-perl/ Chapter 10: Modules, Chapter 11: Object-Oriented Perl

In perl, you use package to create namespaces

package Foo; sub new {} # Foo::new, Foo->new package Bar; sub new {} # Bar::new, Bar->new

A module is a namespace associated with a file (Foo.pm) ...

Replies are listed 'Best First'.
Re^2: Module vs Singleton
by Your Mother (Archbishop) on Jul 15, 2011 at 21:26 UTC

    Just wanted to clarify this–

    package Foo; sub new {} # Foo::new, Foo->new

    Those calls to new are not equivalent–

    ~>perl -lwe 'BEGIN{ package Foo; sub new { print shift } } Foo->new; F +oo::new' Foo Use of uninitialized value in print at -e line 1.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://914659]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-04-20 02:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found