Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

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

I will attempt to clarify my previous answer, given questions sent to me offline.

The question is: Why perl generates 'Use of uninitialized value in scalar assignment' only for the second call of foo and not for the both calls? What's the difference?

The first call specifies a key. The value is undefined, but the key is not.
The second one has an undefined key.

Hopefully this code will demonstrate the difference -- the only error generated is when the key is undefined. The value has nothing to do with the problem.

#!/usr/bin/perl use strict; use warnings; my %bar = (); $bar{not_existing} = 1; $bar{"is_existing"} = 1; my $bar1 = $bar{not_existing}; my $bar2 = $bar{"is_existing"}; my $bar3 = $bar{really_not_existing}; my $key4 = "value_not_existing"; my $bar4 = $bar{$key4}; my $key5; my $bar5 = $bar{$key5}; exit; __END__ C:\Steve\devcvs\mapgen>\steve\t\t2.pl Use of uninitialized value $key5 in hash element at C:\steve\t\t2.pl l +ine 19.

In reply to Re: Inconsistency of 'Use of uninitialized value in scalar assignment' warning by marinersk
in thread Inconsistency of 'Use of uninitialized value in scalar assignment' warning by ccn

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 surveying the Monastery: (3)
As of 2024-03-29 02:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found