On Wed, Jul 30, 2014 at 2:27 PM, Martin G. McCormick < mar...@server1.shellworld.net> wrote:
> There are two arrays or lists. One is called > @from_addresses and the other is @destinations. For the program > to work, there must be at least one, possibly many strings in > each of those arrays. Never under any circumstance should there > be an empty @destinations list when there is even one string in > @from_addresses. > I wrote a test for this condition and it seems to be > missing it every time. Here is the test: > > #Is there enough to work with? > die("***YOU MUST HAVE A DESTINATION ADDRESS/NETWORK address.\n") > if (@destinations) && ( ! @from_addresses); > > I then intentionally feed in only one argument, hit > Enter and no die. Perl -d with a break point at the lines in > question lets me see that @from_addresses has the one argument I > entered and @destinations is undefined. It looks like that > should blow the siren, so to speak. > I have no excuse except that I forgot the test and the > code successfully ran for almost a month before someone in our > group forgot the destination and was bewildered by the "Use of > uninitialized" messages. > Should the code > if (@destinations) { #something to do > #code to run > } #something to do > > succeed when there is at least one string in that array and fail > if the array is undefined? > > Thank you. > Martin McCormick > > -- > Your logic is backwards. You are testing for at least one destination with no from_addresses. HTH, Ken