FreakyGreenLeaky has asked for the wisdom of the Perl Monks concerning the following question:
I now want to obtain the list programmatically:package Util::Stuff; use strict; use warnings; package Util::Stuff::aaa1; sub flag { 1 } ... package Util::Stuff::aaa2; sub flag { 0 } ... package Util::Stuff::aaa3; sub flag { 1 } ... ... 1;
Once I have that info in a list, I want to get the flag values: The manual/existing way:Util::Stuff:aaa1 Util::Stuff:aaa2 Util::Stuff:aaa3
The way I'd like:use Util::Stuff; my $temp1 = Util::Stuff::aaa1->flag; my $temp2 = Util::Stuff::aaa2->flag; my $temp3 = Util::Stuff::aaa3->flag;
Any pointers would be appreciated.use Util::Stuff; my @names = **get_package_names(Util::Stuff)** foreach my $name (@names) { push @temp, $name->flag;' }
|
|---|