I have been away for the longest time and happened on this comment today.
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 -
- What is the warning telling me?
- Also what is the difference between calling a function using &subname or subname()
- Where in the manual can I RTFM?
- Perhaps an simple example showing the different scenarios for using the different ways of calling the function
Of all the things I've lost in my life, its my mind I miss the most.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.