lathropr has asked for the wisdom of the Perl Monks concerning the following question:
t1.plpackage prefs; use strict; use Config::IniFiles; our @ISA = qw( Config::IniFiles ); sub new { my $self = shift; my $class = (ref $self) || $self; my $fname = 'fubar.ini'; my $obj; if (-f $fname) { $obj = $self->SUPER::new( -file => $fname ); } else { $obj = $self->SUPER::new(); $obj->SetFileName( $fname ); $obj->AddSection( 'fubar1' ); $obj->newval('var1=default'); } return bless($obj, $class); } sub DESTROY { my $self = shift; $self->RewriteConfig(); $self->SUPER::DESTROY(@_); } 1;
t2.pl#!/usr/bin/perl -I. use strict; use prefs; my $inifile = new prefs;
t1.pl works. t2.pl fails with a file called "fubar.ini-new". The only difference between the two is the creation of $inifile. One uses "my" and the other users "our". Any suggestions? Thanks, Randal#!/usr/bin/perl -I. use strict; use prefs; our $inifile = new prefs;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: my VS. our
by trammell (Priest) on May 26, 2005 at 19:48 UTC | |
by lathropr (Initiate) on May 26, 2005 at 20:15 UTC | |
|
Re: my VS. our
by rlucas (Scribe) on May 26, 2005 at 19:45 UTC | |
by lathropr (Initiate) on May 26, 2005 at 20:11 UTC |