develooper Front page | perl.perl5.porters | Postings from November 1999

[ID 19991124.002] misleading error message

Thread Previous | Thread Next
Michael Stevens
November 24, 1999 09:54
[ID 19991124.002] misleading error message
Message ID:
This is a bug report for perl from,
generated with the help of perlbug 1.20 running under perl 5.00404.

[Please enter your report here]

mstevens@wildcat:~> cat 

@array = (1, 2, 3);

map { next if (2 == 2); } @array;

mstevens@wildcat:~> perl
Can't "next" outside a block at line 5.

The error generated claims that next is outside a block, but
the documentation below states that next is inside a block. I'm 
told that perl 5.005_03 produces the same behaviour but I don't
have a copy available to test.

mstevens@wildcat:/usr/local/bin> perldoc -f map
=item map BLOCK LIST

=item map EXPR,LIST

Evaluates the BLOCK or EXPR for each element of LIST (locally setting $_ to each
element) and returns the list value composed of the results of each such
evaluation.  Evaluates BLOCK or EXPR in a list context, so each element of LIST
may produce zero, one, or more elements in the returned value.

    @chars = map(chr, @nums);

translates a list of numbers to the corresponding characters.  And

    %hash = map { getkey($_) => $_ } @array;

is just a funny way to write

    %hash = ();
    foreach $_ (@array) {
        $hash{getkey($_)} = $_;

Note that, because $_ is a reference into the list value, it can be used
to modify the elements of the array.  While this is useful and
supported, it can cause bizarre results if the LIST is not a named
array.  See also L</grep> for an array composed of those items of the 
original list for which the BLOCK or EXPR evaluates to true.

[Please do not change anything below this line]

Site configuration information for perl 5.00404:

Configured by torin at Wed Feb  3 00:50:04 PST 1999.

Summary of my perl5 (5.0 patchlevel 4 subversion 4) configuration:
    osname=linux, osvers=2.0.36, archname=i386-linux
    uname='linux perv 2.0.36 #2 wed nov 18 03:00:48 pst 1998 i686 unknown '
    hint=recommended, useposix=true, d_sigaction=define
    bincompat3=n useperlio=undef d_sfio=undef
    cc='cc', optimize='-O2', gccversion=
    cppflags='-Dbool=char -DHAS_BOOL -D_REENTRANT'
    ccflags ='-Dbool=char -DHAS_BOOL -D_REENTRANT'
    stdchar='char', d_stdstdio=define, usevfork=false
    voidflags=15, castflags=0, d_casti32=define, d_castneg=define
    intsize=4, alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldbm -ldb -ldl -lm -lc -lposix -lcrypt
    libc=, so=so
    useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:

@INC for perl 5.00404:

Environment for perl 5.00404:
    LANG (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PERL_BADLANG (unset)

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About