in reply to Testing package membership
If you are testing for methods you can:
use strict; use warnings; use strict; package Abc; sub new { return bless {}, shift; } sub attrib1 { 1 } sub attrib2 { 10 } package main; my $abc = Abc->new (); for my $methName (qw(attrib1 attrib2 attrib3)) { next unless my $meth = $abc->can ($methName); print "Can $methName: ", $meth-> (), "\n"; }
Prints:
Can attrib1: 1 Can attrib2: 10
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Testing package membership
by FreakyGreenLeaky (Sexton) on Nov 21, 2008 at 09:01 UTC | |
by GrandFather (Saint) on Nov 21, 2008 at 09:43 UTC | |
by LanX (Saint) on Nov 21, 2008 at 10:19 UTC |