in reply to "Useless use of private variable in void context"
I concur with chromatic that the line you posted almost certainly isn't the line that is causing the error.
The binary chop technique of commenting out lumps of code is a very useful one, but isn't always practical. Often commenting out one block of code early in the routine, causes so many errors later in the code that the compiler aborts before it ever gets to the error you're trying to find. Another technique I picked up somewhere is to introduce a deliberate but benign error, one that won't cause the compiler to abort, and then move this slowly through the code until it transitions from appearing before the error you're trying to track down to after.
Here it is before
#! perl -slw use strict; my $deliberate_error=''; my $i; length $deliberate_error; $i; __END__ D:\Perl\test>test Useless use of length in void context at D:\Perl\test\test.pl8 line 7. Useless use of private variable in void context at D:\Perl\test\test.p +l8 line 9.
And here after
#! perl -slw use strict; my $deliberate_error=''; my $i; $i; length $deliberate_error; __END__ D:\Perl\test>test Useless use of private variable in void context at D:\Perl\test\test.p +l8 line 7. Useless use of length in void context at D:\Perl\test\test.pl8 line 9.
Simplistic, but it can sometimes be very effective.
Wouldn't it be nice if the error reported was
Useless use of $i in void context at ....
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: "Useless use of private variable in void context"
by Seumas (Curate) on Jun 20, 2003 at 21:42 UTC | |
by BrowserUk (Patriarch) on Jun 20, 2003 at 22:00 UTC | |
by Seumas (Curate) on Jun 20, 2003 at 22:06 UTC | |
by BrowserUk (Patriarch) on Jun 20, 2003 at 22:27 UTC | |
|
Re: Re: "Useless use of private variable in void context"
by Seumas (Curate) on Jun 20, 2003 at 22:03 UTC | |
by BrowserUk (Patriarch) on Jun 20, 2003 at 22:18 UTC | |
by BrowserUk (Patriarch) on Jun 20, 2003 at 22:50 UTC | |
by Anonymous Monk on Aug 22, 2008 at 20:57 UTC | |
by BrowserUk (Patriarch) on Aug 22, 2008 at 22:31 UTC |