Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of uninitialized value in split #3252

Closed
p5pRT opened this issue Jan 23, 2001 · 2 comments
Closed

Use of uninitialized value in split #3252

p5pRT opened this issue Jan 23, 2001 · 2 comments

Comments

@p5pRT
Copy link

p5pRT commented Jan 23, 2001

Migrated from rt.perl.org#5431 (status was 'resolved')

Searchable as RT5431$

@p5pRT
Copy link
Author

p5pRT commented Jan 23, 2001

From manfred.umbach@DaimlerChrysler.com

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";

Perl Info

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

@p5pRT
Copy link
Author

p5pRT commented Jan 23, 2001

From [Unknown Contact. See original ticket]

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.

I reproduced this bug with perl5.6.0 on solaris.

It is fixed in perl5.6.1 and perl5.7.0

I think the patch is 6172 (aka 7330 in perl5.6.1)

This bug should closed

Robin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant