in reply to Object get method as variable name
Consider the following:
which may give you some enlightenment that you seek.#!/usr/bin/perl -w use strict; my $s = new speak(); foreach my $critter(qw/ cat dog spider /){ $s->$critter(); } exit(0); package speak; sub new { bless {},"speak"; } sub cat { print "meow!\n"; } sub dog { print "woof!\n"; } sub spider { print "arf!\n"; } 1;
When run it yields:
Hope this is of some help.$ ./doit.pl meow! woof! arf!
|
|---|