neilwatson has asked for the wisdom of the Perl Monks concerning the following question:
# This array of hashes keeps track of all test results my @tests = ( { name => 'Ping Test', subname => \&pingtest, result => 'Not performed' }, { name => 'Remdial', subname => \&remdial, result => 'Not performed' } ); # Loop through array of hashes and perform each test subroutine. foreach $x (@tests){ # Call subroutine. # What is the correct way to state this? # Without the references I would normally state # $result = testsub(); $x->{'result'} = $x->{'subname'}->(); print $x->{'result'}."\n"; # Stop testing if there is a failure. if ($x->{'result'} =~ m/Fail/) { last; } }
Neil Watson
watson-wilson.ca
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Syntax to call a subroutine from a reference
by chester (Hermit) on Sep 21, 2005 at 18:14 UTC | |
|
Re: Syntax to call a subroutine from a reference
by davidrw (Prior) on Sep 21, 2005 at 18:08 UTC | |
by herveus (Prior) on Sep 21, 2005 at 18:17 UTC | |
|
Re: Syntax to call a subroutine from a reference
by herveus (Prior) on Sep 21, 2005 at 18:13 UTC | |
|
Re: Syntax to call a subroutine from a reference
by sh1tn (Priest) on Sep 21, 2005 at 18:10 UTC | |
|
Re: Syntax to call a subroutine from a reference
by neilwatson (Priest) on Sep 21, 2005 at 18:26 UTC |