package Menu; use strict; use Data::Dumper; sub new { my ($self, %args) = @_; bless { _title => $args{title} || die "Sorry, we need a title for this menu!", _header => $args{header}, _comment => $args{comment} }, $self; } sub set_choices { my ($self, %choices) = @_; my $count; foreach (keys %choices) { $self->{$_} = ( _id => $_, _name => $choices{$_}{name} || die "Sorry, we need a name for this menu entry!", _sub_or_id => $choices{$_}{sub_or_id} || 0, _return_sub => $choices{$_}{return_sub} ); } } sub print { my $self = shift; print Dumper $self; } 1;