develooper Front page | perl.perl5.porters | Postings from January 2001

[ID 20010123.029] Use of uninitialized value in split

Thread Next
From:
manfred.umbach
Date:
January 23, 2001 06:54
Subject:
[ID 20010123.029] Use of uninitialized value in split
Message ID:
200101231452.PAA159253@pcd.daimler-benz.com
This is a bug report for perl from manfred.umbach@daimlerchrysler.com,
generated with the help of perlbug 1.28 running under perl v5.6.0.


-----------------------------------------------------------------
[Please enter your report here]

The following script splits a string into paragraphs at empty lines.
While working well under perl 5.005, with perl 5.6 I get a warning
"Use of uninitialized value in split" and the split is done
incompletely (only 9 paragraphs are detected instead of 10).

The behavior depends critically on the contents of the string and the
error seems to occur only if the "-w" flag is present.  In particular,
modifications of the number of lines in general cause the error to
vanish, but there are many settings of the string where the error
occures.  The string in the script below was the shortest of that kind
I could find in an afternoon trial and error work.

The problem occurs on AIX 4.3.3, HP-UX 11, IRIX 6.5 and Windows NT.


#!/usr/local/bin/perl -w

use strict;

my $string = "
paragraph  1
x

paragraph  2
x
x
x
x

paragraph  3

paragraph  4
x
x
x
x
x
x

paragraph  5
x

paragraph  6
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x

paragraph  7
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x

paragraph  8
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x

paragraph  9
x

paragraph 10
x
";

my @paras = split( /^\s*\n/m , $string );

print "number of paragraphs: ", @paras-1, "\n\n",
      "first paragraph:\n", $paras[1], "\n",
      "last paragraph:\n", $paras[-1], "\n";


[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=medium
---
Site configuration information for perl v5.6.0:

Configured by root at Thu May 18 08:18:56 CEST 2000.

Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
  Platform:
    osname=irix, osvers=6.5, archname=IP30-irix
    uname='irix64 sgiinst 6.5 01200532 ip30 '
    config_args='-Dprefix=/usr/local/perl/5.6.0'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define 
    use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef
  Compiler:
    cc='cc -n32', optimize='-O3', gccversion=
    cppflags='-D_BSD_TYPES -D_BSD_TIME -OPT:Olimit=0:space=ON -I/usr/local/include -I/usr/gnu/include -DLANGUAGE_C'
    ccflags ='-D_BSD_TYPES -D_BSD_TIME -woff 1009,1110,1174,1184,1552 -OPT:Olimit=0:space=ON -I/usr/local/include -I/usr/gnu/include -DLANGUAGE_C'
    stdchar='unsigned char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc -n32', ldflags =' -L/usr/local/lib32 -L/usr/local/lib -Wl,-woff,84 -L/usr/gnu/lib'
    libpth=/usr/local/lib /usr/gnu/lib /usr/lib32 /lib32 /lib /usr/lib
    libs=-ldb -lm -lc
    libc=/usr/lib32/libc.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-n32 -shared -L/usr/local/lib32 -L/usr/local/lib -L/usr/gnu/lib'

Locally applied patches:
    

---
@INC for perl v5.6.0:
    /usr/local/perl/5.6.0/lib/5.6.0/IP30-irix
    /usr/local/perl/5.6.0/lib/5.6.0
    /usr/local/perl/5.6.0/lib/site_perl/5.6.0/IP30-irix
    /usr/local/perl/5.6.0/lib/site_perl/5.6.0
    /usr/local/perl/5.6.0/lib/site_perl
    .

---
Environment for perl v5.6.0:
    HOME=/home/umbach
    LANG=C
    LANGUAGE (unset)
    LC_CTYPE=en
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/lib/SoftWindows/bin:/home/umbach/bin/iris4d/IRIX64-6.5:/home/umbach/bin/iris4d:/home/umbach/bin:/usr/local/bin:/usr/bsd:/usr/sbin:/bin:/usr/bin:/usr/bin/X11:/usr/freeware/bin:.:/usr/java/bin:/usr/atria/bin:/adtk/shell:/adtk/bin_cdc:/home/umbach/script:/home/umbach/perl:/usr/java/bin:/cdw/bin
    PERL_BADLANG (unset)
    SHELL=/bin/tcsh


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About