D
Derek Basch
Hi Everyone,
I began using Class:BI and love it. However, there are situations
where I want to loop through the Class::Accessor accessors for an
object and also get the name of the accessor as I loop through.
For instance here is some psuedo-perl that I wrote to visualize what I
need:
# returns an array of objects
my @gpsaccounts = Database::Members::Gpsaccounts->search($user_id);
# loop through the array of objects
foreach my @row_class (@gpsaccounts) {
# loop through the objects accessors
foreach $class_accessor (@row_class) {
# print the accessors name and value
print "$class_accessor_name: $class_accessor_value\n"
}
}
Yes, I know that the above is syntactically unpossible but I don't know
how else to express it.
Here's how you would normally do it:
my @gpsaccounts =
Database::Members::Gpsaccounts->search_gpsaccounts($user_id);
foreach(@gpsaccounts) {
print $_->fullname . "\n";
print $_->user . "\n";
print $_->email . "\n";
print "------------------------" . "\n";
}
Any ideas? I am a newer Perl programmer so any help is appreciated.
Thanks,
Derek Basch
I began using Class:BI and love it. However, there are situations
where I want to loop through the Class::Accessor accessors for an
object and also get the name of the accessor as I loop through.
For instance here is some psuedo-perl that I wrote to visualize what I
need:
# returns an array of objects
my @gpsaccounts = Database::Members::Gpsaccounts->search($user_id);
# loop through the array of objects
foreach my @row_class (@gpsaccounts) {
# loop through the objects accessors
foreach $class_accessor (@row_class) {
# print the accessors name and value
print "$class_accessor_name: $class_accessor_value\n"
}
}
Yes, I know that the above is syntactically unpossible but I don't know
how else to express it.
Here's how you would normally do it:
my @gpsaccounts =
Database::Members::Gpsaccounts->search_gpsaccounts($user_id);
foreach(@gpsaccounts) {
print $_->fullname . "\n";
print $_->user . "\n";
print $_->email . "\n";
print "------------------------" . "\n";
}
Any ideas? I am a newer Perl programmer so any help is appreciated.
Thanks,
Derek Basch