Dear Perl people, I'm just wondering about the set up of class variables in a Perl class. Say I have something like the following:
======================
sub new
{
# fetch class name
my $class = shift;
# create object
my $self = {
_path => shift,
};
# open input definition file
open(DEF, $self->{_path})
or die "\n"
. __PACKAGE__
. ": Couldn't open definition file for reading! - "
. $self->{_path}
. "\n";
# read in entire file
# @def is a global variable here, global in the module only that is
@def = <DEF>;
bless $self, $class;
}
======================
Now, with the initialisation of the global @def array, is there any benefit
of initialising this array as
$self->{_def => <DEF>} instead of having an explicit global array @def?
Thanks for any advice,
Mk
<<attachment: winmail.dat>>
