in reply to Creating variables for each array member
use ButtonJar; my $jar = ButtonJar -> new(); $jar -> add( $but1 );
package ButtonJar; sub new { my $self = shift; $self = {}; return bless $self; } sub add { # add a button to the "jar" my $self = shift; my $but = shift; $self -> { $but -> id() } = $but; sub remove { # remove a button my $self = shift; my $but = shift; delete $self -> { $but -> id() }; } sub getall ( my $self = shift; return keys %$self; # to return the $widget -> id # or could return values %$self or just %$self # depending on how you want to reference your buttons } 1;
-M
Free your mind
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Creating variables for each array member
by jdtoronto (Prior) on Jul 25, 2006 at 12:29 UTC | |
by Moron (Curate) on Jul 25, 2006 at 13:24 UTC | |
by GrandFather (Saint) on Jul 26, 2006 at 20:44 UTC | |
by Moron (Curate) on Jul 27, 2006 at 10:02 UTC |