Hi everyone
I found a run error in my code and after a very long time,
I've determined which code line is the 1 responsible for adding an element to my array.
The weird thing is that this line only "looks" at the element, not setting it !
Basically it looks like it is being created because it was "looked" at (very "Heisenberg's uncertainty principle" like).
Hereis my code:
if($cond->{Par} =~ /^K(\d+)/)
{
my $qqq = scalar(@{$this->{N}});
$testedNVal = $this->{N}[$1]{Val}; # freak line
unless($qqq == scalar(@{$this->{N}}))
{print 'how is this possible ?';<>;}
}
By substituting for
$testedNVal = 0 + $this->{N}[$1]{Val};, I could determine the print only occurs when
$this->{N}[$1]{Val} is undef (by 'num + undef' warning).
(The new element is a ref, referring an empty hash)
I figured maybe by setting ("=") it directly to a var, I create a reference to something and force it to exist, but if that's correct than the "= 0 +" shouldn't have done the same thing (but it did).
Can someone please explain whats going on, and how can I solve it ?
(if I even ask if it's exists/defined I'll create it by access so.. ?)
Thoughts ?
Thx
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.