Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re^3: Unexpected warning

by salva (Abbot)
on Nov 18, 2013 at 15:08 UTC ( #1063114=note: print w/replies, xml ) Need Help??

in reply to Re^2: Unexpected warning
in thread Unexpected warning

I can reproduce it myself too now:
tst(undef); # doesn't warn from tst tst($foo{undef}); # doesn't warn from tst tst($foo{$undef}); # warns from tst
I would say this is a bug in perl, or I am missing something?

Replies are listed 'Best First'.
Re^4: Unexpected warning
by samwyse (Scribe) on Nov 18, 2013 at 16:14 UTC

    The undef value is subtly different from using an undefined variable, so that may be causing the problem.

    tst($foo{undef});  # doesn't warn from tst

    This uses the undef value as a key into the %foo hash; the key presumably doesn't exist so Perl returns undef. This is working as I would expect.

    tst($foo{$undef});  # warns from tst

    This looks up the value of $undef, which presumably isn't defined, so Perl should flag an error at that statement, not inside tst. If that is the case, then it, too, is working as I would expect.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1063114]
[ovedpo15]: can't I use just use lib $FindBin::Bin/../ bin" asuming that p2 is in ./bin and p1 is in /config? it says "cant find" altought p2 is
[moritz]: ovedpo15 "use lib" is only for .pm files
[moritz]: if you don't have .pm file, you might to use "require" or "do" with an absolute path
[ovedpo15]: I need to use FindBin thought. does FindBin finds only modules? or it can find perl script also?
[moritz]: maybe you should start looking at the documentation of FindBin?

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2018-03-17 20:47 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (226 votes). Check out past polls.