Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • by mauzo (8185) on 2008.02.26 15:38 (#61350)
    Having just got your bug reports, I'm in the middle of writing a test suite now... I wrote E::NW before I'd really cottoned on to the value of testing, and haven't touched it since. I've already found another latent bug.

    Unfortunately, local $_ isn't safe either. If $_ is aliased to a member of a tied hash or array, it isn't localised properly and the value in the hash is affected as well:

    tie my %h, 'Tie::StdHash';
    $h{a} = 1;
    for ($h{a}) {
        local $_ = 2;
        print $h{a};    # 2, but should be 1
    print $h{a};        # back to 1 again
    If you call external code in the scope of the change (as E::NW does) this could be a problem. The workarounds are either to localise all of *_ which, besides being ugly, clobbers @_ as well, or to use for instead of assigning to $_ at all. for doesn't suffer from this problem, and neither does 5.10's my $_.
    • Oh, nice catch. We've got local workarounds in place, but I'm happy to know that you've spotted more than I did :)