05 Feb 2011 03:35:20 UTC
- Distribution: Class-Fields
- Module version: 0.04
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (0)
- Testers (1251 / 0 / 0)
- KwaliteeBus factor: 0
- 78.80% Coverage
- License: perl_5
- Activity24 month
- Download (15.32KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest versionMSCHWERN Michael G Schwernand 1 contributors
- Michael G Schwern
Take me over?The maintainer of this distribution is looking for someone to take over! If you're interested then please contact them via email.
private - Add private data members to Perl classes
package GI::Joe; use private qw( _SexualPrefs _IsSpy ); # see the protected man page for an example
- Private member.
Internal data or functionality. An attribute or method only directly accessible to the methods of the same class and inaccessible from any other scope. In Perl, notionally private attributes and members are conventionally given names beginning with an underscore.
From "Object Oriented Perl" by Damian Conway
private.pm adds a list of keys as private data members to the current class. See public for more info.
Private data members are those pieces of data which are expected to be only accessed by methods of the class which owns them. They are not inherited by subclasses.
private.pm serves a subset of the functionality of fields.pm.
use private qw(_Foo);
is almost exactly the same as:
use fields qw(_Foo);
with the exception that you can (if you REALLY want to) do something like this:
use private qw(Foo);
Whereas one cannot do this with fields.pm. (Note: This is considered unwise and private.pm will scream about it if you have Perl's warnings on.)
Additionally, private.pm is a bit clearer in its intent and is not necessarily implying use of pseudo-hashes.
See "SYNOPSIS" in protected for an example of use.
I fully expect private.pm to eventually mutate into a real pragma someday when a better formalized OO data system for Perl supplants the current fledgling pseudo-hashes.
Michae G Schwern <firstname.lastname@example.org>
Module Install Instructions
To install Class::Fields, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Class::Fields
For more information on module installation, please visit the detailed CPAN module installation guide.