gwowi has asked for the wisdom of the Perl Monks concerning the following question:
I am currently creating a script which will run on windows computer.
This script will test a lot of the system settings.
Tests will be often added or removed.
If I try to use the code below, I got the following message: "Can't use string ("test1") as a subroutine ref while "strict refs" in use at testlist.pl line 10."
I understand the error message, but what should be the best and easy way to avoid this situation? (I can ommit the "use strict", but it is not the way I want to do it)
use strict; use warnings; my @testlist=('test1','test2'); foreach (@testlist) { print ("dear user test $_ is currently running\n"); #call test &$_(); } sub test1 { #test1 code print "test1...done\n"; } sub test2 { #test2 code print "test2...done\n"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: strict refs usage
by GrandFather (Saint) on Sep 22, 2005 at 10:04 UTC | |
by gwowi (Acolyte) on Sep 26, 2005 at 14:16 UTC | |
Re: strict refs usage
by VSarkiss (Monsignor) on Sep 22, 2005 at 14:05 UTC | |
Re: strict refs usage
by Anonymous Monk on Sep 22, 2005 at 09:59 UTC | |
Re: strict refs usage
by splinky (Hermit) on Sep 22, 2005 at 15:47 UTC | |
Re: strict refs usage
by chromatic (Archbishop) on Sep 22, 2005 at 16:40 UTC | |
by QM (Parson) on Sep 22, 2005 at 18:20 UTC | |
by chromatic (Archbishop) on Sep 22, 2005 at 18:48 UTC | |
Re: strict refs usage
by Tanktalus (Canon) on Sep 22, 2005 at 14:47 UTC | |
Re: strict refs usage
by tphyahoo (Vicar) on Sep 24, 2005 at 11:03 UTC |