Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: RFC: Adding variable name to warning "Use of uninitialized value ??? in ..."

by dave_the_m (Prior)
on Apr 15, 2017 at 14:04 UTC ( #1188001=note: print w/replies, xml ) Need Help??


in reply to RFC: Adding variable name to warning "Use of uninitialized value ??? in ..."

My implementation in the perl core was a compromise between complexity, performance and convenience. It's currently about 750 lines of src code. It could certainly be expanded to extract the variable name under more circumstances, but I had to draw a line somewhere.

Note also that it's quite hard to avoid false positives. For example, for an empty array @a, in $a[0] + $a[1] at the time of execution of the addition, both args are the same special address &PL_sv_undef, so its not possible to determine whether a particular undef value came from the LHS or the RHS.

Dave.

Replies are listed 'Best First'.
Re^2: RFC: Adding variable name to warning "Use of uninitialized value ??? in ..."
by LanX (Bishop) on Apr 15, 2017 at 14:22 UTC
    Hi Dave

    Thanks for the feedback :)

    > My implementation in the perl core was a compromise between complexity, performance and convenience. 

    I know, and this is in no way a criticism of your implementation! I'm aware of the complexity.

    I want to open an opportunity to better inspect problems in pure Perl.

    At work we are using many here docs and help in faster identifying root problems would be appreciated.

    See it as a potential add on module like diagnostics and not as a feature request for core.

    > It's currently about 750 lines of src code. It could certainly be expanded to extract the variable name under more circumstances, but I had to draw a line somewhere.

    That's why I'm delegating the hard part to B::Deparse

    > Note also that it's quite hard to avoid false positives

    That's why I'm reporting all potential culprits with undef values in the first warning and ignoring all other warnings from the same line.

    I don't want to risk that a true positive gets lost because of a false positive.

    It's up to the user to find out which are real.

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1188001]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2017-12-16 17:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (457 votes). Check out past polls.

    Notices?