Ntav has asked for the wisdom of the Perl Monks concerning the following question:
problem: I'm adding elements to an array according to positions defined in a lookup table, so when it comes time to print the array some elements are undefined.(this is the correct behaviour - not to be "fixed")
current solution: when printing, I test:
question: So, learned monks, what is the smart solution?
Thanks,
Ntav
Not Another Perl Hacker
In fact I'm more used to declarative programming so the above code looks rather odd to me!
current solution: when printing, I test:
and though this works (i.e. when I print I don't try and print an uninitialized variable) if I execute with warnings on, perl complains.if($array[$i][$j] == 0){ $array[$i][$j] = 0;}
question: So, learned monks, what is the smart solution?
Thanks,
Ntav
Not Another Perl Hacker
In fact I'm more used to declarative programming so the above code looks rather odd to me!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: undefined elements in array
by jlongino (Parson) on Sep 09, 2001 at 15:59 UTC | |
Re: undefined elements in array
by demerphq (Chancellor) on Sep 09, 2001 at 19:38 UTC | |
Re: undefined elements in array
by bless$self=>perlmonks; (Novice) on Sep 09, 2001 at 18:09 UTC | |
Re: undefined elements in array
by tachyon (Chancellor) on Sep 10, 2001 at 02:39 UTC | |
by Anonymous Monk on Aug 20, 2013 at 13:35 UTC | |
by Athanasius (Archbishop) on Aug 20, 2013 at 14:17 UTC |
Back to
Seekers of Perl Wisdom