sisters, bwothers,

Like the title says, undef is giving me horrible nightmares all of a sudden. I have two variables which I use in a for loop. At the end of that loop, I undef two variables, which are created at the beginning of the loop. Now, in one cycle, the two variables were not empty et al, and contained data from a previous loop... which of course caused lots of evil ;-)

my code looks something like this:

for my $mode (@probe_modes) { my (@source,@destination); create_map_file $mode; get_elements; # @source and @destination are filled here scan_matrix $mode; undef(@source); undef(@destination); }

I'm sure it's the undef that's causing the problem, because the first two subroutines should first check if the arrays need to be filled, and one will actually fill. The one that's checking reports that it's not going to fill (and it doesn't, i checked) and the second one says it's not filling, but there's data in the array of the previous loop.

I'm using:

This is perl, v5.6.1 built for sun4-solaris-64int (with 48 registered patches, see perl -V for more detail) Summary of my perl5 (revision 5.0 version 6 subversion 1) configuratio +n: Platform: osname=solaris, osvers=2.9, archname=sun4-solaris-64int uname='sunos localhost 5.9 sun4u sparc sunw,ultra-1' config_args='' hint=recommended, useposix=true, d_sigaction=define usethreads=undef use5005threads=undef useithreads=undef usemultipl +icity=undef useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef use64bitint=define use64bitall=undef uselongdouble=undef Compiler: cc='cc', ccflags ='-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-xO3 -xdepend', cppflags='' ccversion='Sun WorkShop', gccversion='', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=87654321 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=1 +6 ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='of +f_t', lseeksize=8 alignbytes=8, usemymalloc=n, prototype=define Linker and Libraries: ld='cc', ldflags ='' libpth=/lib /usr/lib /usr/ccs/lib libs=-lsocket -lnsl -ldl -lm -lc perllibs=-lsocket -lnsl -ldl -lm -lc libc=/lib/libc.so, so=so, useshrplib=true, libperl=libperl.so Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-R /usr/ +perl5/5.6.1/lib/sun4-solaris-64int/CORE' cccdlflags='-KPIC', lddlflags='-G'
Thanks !
--
to ask a question is a moment of shame
to remain ignorant is a lifelong shame

In reply to The weirdest problem with undef by insaniac

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.