Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: determine the variable causing the error: Use of uninitialized value

by ruqui (Acolyte)
on Apr 13, 2017 at 19:23 UTC ( [id://1187869]=note: print w/replies, xml ) Need Help??


in reply to Re^2: determine the variable causing the error: Use of uninitialized value
in thread determine the variable causing the error: Use of uninitialized value

AnomalousMonk it's correct what you say, but it only work with scalars, it doesn't work with more complex structures like hashes (or references to hashes):

EXAMPLE:

perl -wMstrict -le 'print qq{perl version: $] \n};;; my $x; my %y= (" +h"=>1, "i"=>2); print $x, $y{x}; printf "%s", $x;'
OUTPUT:
perl version: 5.018002 Use of uninitialized value $x in print at -e line 1. Use of uninitialized value in print at -e line 1. Use of uninitialized value $x in printf at -e line 1. </b>

Replies are listed 'Best First'.
Re^4: determine the variable causing the error: Use of uninitialized value
by LanX (Saint) on Apr 13, 2017 at 19:35 UTC
    > it doesn't work with more complex structures like hashes (or references to hashes)

    To rephrase it, your problem are undefined elements of data structures like $h{x}.

    I don't think there is any out of the box solution and you'd need to send a feature request.

    As a side note: a hack could be to add a signal handler which parses the OP tree at the caller for all undefined entries .

    But that's far from trivial.

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

      Thank you for your suggestion Rolf, what should I do in order to send a feature request?
        I'm sorry but chances are too low, if you follow the discussion, especially the contributions by Dave_the_m you will see that is far too complicated too implement in core.

        update
        Anyway I've already shown code to help you in a pragmatic way

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1187869]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-25 05:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found