Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: Easy hash question (uninitialized value)

by Lotus1 (Priest)
on May 16, 2018 at 13:54 UTC ( #1214657=note: print w/replies, xml ) Need Help??

in reply to Easy hash question (uninitialized value)

Also check out the function exists. It lets you test if a key is in a hash. In this case it would help you debug but it's useful in general for validating hash keys, especially when they come from user input.

I added the following at the end of your script:

if( exists $j{$number} ) { say $j{$number}; say "done"; } else { say "<$number> is not a key in \%j" }

Here is the result of running it:

C:\usr\pm\hash>perl 4 4 <4 > is not a key in %j

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2018-07-22 01:16 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (451 votes). Check out past polls.