> > >
> > > But you get to populate %_default, right? So you can make
> > > sure that the
> > > keys are uppercase. I don't understand why you do this tr.
> >> >The user will not populate the %_default.
>
> Right, that's what I meant, you're populating it. So I don't
> see that you
> need to use code to make sure that you put the keys in uppercase.
Well, it is populated at the outset. I thought this code would suffice to
making sure the keys of %args are uppercase:
my ($argname) = ($attr =~ tr/a-z/A-Z/);
but a second look makes me not so sure so here is how I have it now
my $argname;
foreach my $attr ( keys %_default ) {
if (exists $args{$argname})
{ $self->{$attr} = uc($args{$argname}) }
else
{ $self->{$attr} = $_default{$attr} }
}
>
> >That hash is there to provide
> >default values and make sure the args passed our allowable.
> The args being
> >passed to the constructor will go into %args. So if the user
> creates and
> >object like this:
> >my $log = new Logs (FILE => 'mylogfile',
> > FORM => 'htm'
> >);
> >%args will not contain: FILE => 'mylogfile',FORM => 'htm'
>
> "not"? I think you mean "now".
yep, sorry again.
> >
> > >
> > > > if (exists $args{$argname}) # match
> > > against %args
> > > >
> > > > { $self->{$attr} = $args{$argname} } # if
> > > the arg key exists
> > > >use that
> > > > else
> > > > { $self->{$attr} = $self->_default($attr) } #
> > > if not use defualt
> > > >}
> > >
> > > I assume that _default is a method that accesses %_default,
> >
> >woops, that was a typo, is should be:
> >{ $self->{$attr} = $self->$_default($attr) }
>
> I don't think so, that would call the method named by the
> scalar $_default
> and pass it $attr as argument. I think you mean
>
> $self->{$attr} = $_default{$attr}
yes, you are correct again. I think I will get some sleep tonight for
a change :-)
--
any way, after playing around with your suggestion..it works.
Thanks again
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]