Mohammed Khatib wrote:
> 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?

What happens to @def on your second new call ?

-- 
  ,-/-  __      _  _         $Bill Luebkert    Mailto:[EMAIL PROTECTED]
 (_/   /  )    // //       DBE Collectibles    Mailto:[EMAIL PROTECTED]
  / ) /--<  o // //      Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_    http://dbecoll.tripod.com/ (Free site for Perl/Lakers)


_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to