Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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 ....


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller



In reply to Re: "Useless use of private variable in void context" by BrowserUk
in thread "Useless use of private variable in void context" by Seumas

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (1)
As of 2024-04-25 00:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found