in reply to OO Simple THing

Try the following:
package Round; sub new { my $class = shift; my %args = @_; my $self = {}; $self->{_$_} = $args{$_} for qw( roundnum room judge type code contestants ); bless $self, $class; } sub roundnum { my $self = shift; $self->{_roundnum} = shift if @_; $self->{_roundnum}; } ------------- use Round; my $test = Round->new( roundnum => 1 ); my $testval = $test->roundnum; print "$testval\n";

That should give you the answer you're looking for.

------
We are the carpenters and bricklayers of the Information Age.

Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

Replies are listed 'Best First'.
Re: Re: OO Simple THing
by Fletch (Bishop) on Mar 29, 2004 at 02:50 UTC

    ITYM $self->{"_$_"}. What you've got compiles into $self->{$_->_}.

    $ perl -MO=Deparse -e 'print $self->{_$_};' print $$self{$_->_};
Re: Re: OO Simple THing
by cormac (Acolyte) on Mar 29, 2004 at 02:34 UTC
    $self->{_$_} = $args{$_} for qw( roundnum room judge type code contestants );

    The "_NAME" convention's purpose is a mnemonic one, and this (purpose) is not well served when used on $_. Don't you think it's better to use a named lexical for the for(each)?s scope here, dude?

    --
    Real men use curlies.