AcidHawk has asked for the wisdom of the Perl Monks concerning the following question:
A bigger issue is using &subname to call subs instead of subname() - that really doesn't do what you think it does. - in this thread Re: What to use instead of global variables
So I wondered what the difference was. I wrote the following as a SIMPLE test to see if anything jumped out at me.
#!/usr/bin/perl use strict; use warnings; print "About to test sub calls using \& --\n"; &test1; print "About to test sub call using name() --\n"; test2(); sub test1() { print "test1: Working\n"; } sub test2() { print "test2: Working\n"; }
When I do a "perl -c myScript.pl" I get the following
main::test2() called too early to check prototype at myScript.pl line 10. myScript.pl syntax OK
And when I run the script it seems to work with no problems. Other than I get the same warning and in the syntax check before the output. Now I do realise that I could simply remove the use warnings; from my script but I was wondering -
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Calling Functions
by AcidHawk (Vicar) on Mar 28, 2012 at 08:01 UTC | |
by GrandFather (Saint) on Mar 28, 2012 at 08:39 UTC | |
by eclpmb (Hermit) on Mar 28, 2012 at 08:31 UTC | |
|
Re: Calling Functions
by Happy-the-monk (Canon) on Mar 28, 2012 at 08:37 UTC | |
|
Re: Calling Functions
by JavaFan (Canon) on Mar 28, 2012 at 09:43 UTC | |
|
Re: Calling Functions
by andal (Hermit) on Mar 29, 2012 at 07:33 UTC |