On Sun, Nov 24, 2002 at 12:26:31PM +0100, Mystik Gotan wrote:
> What does the underscore exactly do, when using _var?
> Example:
> package Person;
>    use Carp;
>    our $AUTOLOAD;  # it's a package global
>    my %fields = (
>        name        => undef,
>        age         => undef,
>        peers       => undef,
>    );
>    sub new {
>        my $that  = shift;
>        my $class = ref($that) || $that;
>        my $self  = {
>            _permitted => \%fields,
>            %fields,
>        };
>        bless $self, $class;
>        return $self;
>    }
> 
> Look for the:
> _permitted => \%fields,
> 
> I know it has something to do with "for internal use only". But I need some 
> better explainment. Thanks in advance.

The real answer is that is does nothing special at all.  It's just
another character in a name.  The slightly more useful answer, is that
since Perl contains no enforced privicy of methods or instance variables
(think hash members in this case) the leading underscore, by convention,
means that the variable or method is for internal use only.  This
convention is not followed by all.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to