argv has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w sub handle_error { if (open LOG, ">/dev/null") { carpout(LOG); } } print "hello world.\n";
The intent is to display a very small program to illustrate a problem with a much larger one (whose purpose and design is irrelevant at this point). The problem is, running the program yields a warning from perl:
Name "main::LOG" used only once: possible typo at bar.pl line 4.
The context of LOG's use seems clear that it's a parameter to another function, so it's not "used once." ...at least, not in a way that should warn the user. Now, if perl is going to follow that function to see what its doing with that parameter and seeing that nothing is done, fine. But it isn't, so isn't the warning unnecessary? (If you introduce an actual compile-time error, the warning goes away entirely.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: unnecessary warning message?
by Animator (Hermit) on May 06, 2005 at 20:04 UTC | |
by ysth (Canon) on May 08, 2005 at 16:56 UTC | |
|
Re: unnecessary warning message?
by thundergnat (Deacon) on May 07, 2005 at 14:12 UTC |