Package: perl
Version: 5.8.8-11
Severity: normal

warn without arguments inside a foreach { grep } loop
causes bad things to happen. Test program followed by output:

#!/usr/bin/perl -w
use strict;

# set to 1 to break or 0 to work
my $crash = 1;

my @list = qw/A b C/;
my @loh = map { { name => $_ } } @list;

foreach my $i (grep({ $_->{name} =~ m/[A-Z]/ } @loh)) {
    # this should print out got HASH(...) twice - once for A and once for C
    print "got $i\n";
    # This shouldn't happen, but it does if $crash=1?!
    die "$i is not a hash ref!" if (ref($i) ne 'HASH');

    if ($crash) {
        # this warn seems to screw with the thing that will be the next $i?
        warn;
    } else {
        warn "false alarm, everything is OK";
    }
}



What I get:
[EMAIL PROTECTED] perl broken.pl
got HASH(0x604160)
Warning: something's wrong at broken.pl line 17.
got 1
1 is not a hash ref! at broken.pl line 13.
[EMAIL PROTECTED]

what I expect:
[EMAIL PROTECTED] perl broken.pl
got HASH(0x604160)
Warning: something's wrong at broken.pl line 17.
got HASH(0x628a10)
Warning: something's wrong at broken.pl line 17.
[EMAIL PROTECTED]

-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.22-2-amd64 (SMP w/2 CPU cores)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/bash

Versions of packages perl depends on:
ii  libc6                         2.6.1-6    GNU C Library: Shared libraries
pn  libdb4.6                      <none>     (no description available)
ii  libgdbm3                      1.8.3-3    GNU dbm database routines (runtime
ii  perl-base                     5.8.8-11.1 The Pathologically Eclectic Rubbis
pn  perl-modules                  <none>     (no description available)

Versions of packages perl recommends:
ii  perl-doc                      5.8.8-11   Perl documentation

-- no debconf information



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to