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

[ID 19991124.002] misleading error message

Thread Previous | Thread Next
From:
Michael Stevens
Date:
November 24, 1999 09:54
Subject:
[ID 19991124.002] misleading error message
Message ID:
E11qgcR-0001CT-00@kronos.imaginet.co.uk
This is a bug report for perl from mstevens@imaginet.co.uk,
generated with the help of perlbug 1.20 running under perl 5.00404.


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

mstevens@wildcat:~> cat test.pl 
#!/usr/bin/perl

@array = (1, 2, 3);

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

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

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:
  Platform:
    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
  Compiler:
    cc='cc', optimize='-O2', gccversion=2.7.2.3
    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:
	/usr/lib/perl5/i386-linux/5.004
	/usr/lib/perl5
	/usr/local/lib/site_perl/i386-linux
	/usr/local/lib/site_perl
	.

---
Environment for perl 5.00404:
    HOME=/home/mstevens
    LANG (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/bin:/bin:/usr/bin:/usr/bin/X11:/usr/games:/usr/sbin:/sbin
    PERL_BADLANG (unset)
    SHELL=/usr/bin/zsh

Thread Previous | 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