insaniac has asked for the wisdom of the Perl Monks concerning the following question:
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'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: The weirdest problem with undef
by davorg (Chancellor) on Dec 22, 2004 at 10:09 UTC | |
|
Re: The weirdest problem with undef
by dave_the_m (Monsignor) on Dec 22, 2004 at 10:01 UTC | |
by insaniac (Friar) on Dec 22, 2004 at 10:13 UTC | |
by davorg (Chancellor) on Dec 22, 2004 at 10:22 UTC | |
by insaniac (Friar) on Dec 22, 2004 at 10:26 UTC | |
by insaniac (Friar) on Dec 22, 2004 at 10:32 UTC | |
| |
|
Re: The weirdest problem with undef
by sasikumar (Monk) on Dec 22, 2004 at 11:05 UTC | |
by insaniac (Friar) on Dec 22, 2004 at 11:36 UTC | |
|
Re: The weirdest problem with undef
by steves (Curate) on Dec 22, 2004 at 10:03 UTC | |
|
Re: The weirdest problem with undef
by dirac (Beadle) on Dec 22, 2004 at 15:19 UTC | |
by insaniac (Friar) on Dec 22, 2004 at 15:39 UTC | |
by blazar (Canon) on Jun 28, 2005 at 10:15 UTC | |
|
Re: The weirdest problem with undef
by saberworks (Curate) on Dec 22, 2004 at 18:20 UTC | |
by insaniac (Friar) on Dec 22, 2004 at 19:24 UTC | |
by Jasper (Chaplain) on Dec 23, 2004 at 09:54 UTC | |
by blazar (Canon) on Jun 28, 2005 at 10:18 UTC |