Hello monks,
there are two subroutine calls in the script below.
use warnings;
sub foo { my $val = $_[0]; }
my %bar;
my $baz;
# this line does not generate warnings
foo( $bar{not_existing} );
# this line generates two warnings
foo( $bar{$baz} );
Output I have is the following:
Use of uninitialized value $baz in hash element at t.pl line 10.
Use of uninitialized value in scalar assignment at t.pl line 2.
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?
In both cases @_ in foo contains an alias of not existing value of not existing key of %bar, you know.
-
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.
|