I am attempting to understand why Perl may be incapable of *always* printing the file and line number like the following example. In this simple example and in every Perl .pm or .pl I write seems to work as expected by burping a warning when the condition is detected.

Use of each() on hash after insertion without resetting hash iterator results in undefined behavior, Perl interpreter: 0xed8cd8 at ./each-example.pl line 21.

However, an application I'm coding at work currently has no usage of each(); however while the application runs I randomly received the message above *BUT* without a filename or line number. Figuring Perl wont burp the message unless its real I've combed through the source and found no usage of each(), which is as expected, as I'm not a fond user of it. What I get looks like this:

Use of each() on hash after insertion without resetting hash iterator results in undefined behavior, Perl interpreter: 0x<hex-blah>.

A little back ground: The application runs on Linux, specifically it runs on RH6.7 and uses the Perl RH provides, perl-5.10.1 with various patches RH added via RPM. This version of Perl does not complain about this issue. I've been forced to try and use a newer Perl because the Perl 5.10.1 contains bugs that causes it to received a SIGSEGV (11) because given enough time it will corrupt its heap or something. I attempted to look under Perl's hood by using RH's debug info packages etc and examining core files. It was not useful and the location it pooped out was always random.

I wont bother making a full listing but I've built the latest of every 5.<even>.<latest> release from 5.14.4 and ran regression tests against the application. All of these versions I believe complain about the usage of each(). I wanted to use 5.24.1, thinking I could get support for any issues found however it has a serious memory leak in it. BTW 5.25.<latest> does not the large memory leak. Well I get off topic. Prior to 5.24 version seem to be memory leak free.

I guess the real question is how to determine where this each() warning is coming from? Without a file and line number I'm suspecting this each() is embedded into some XS code that is also compiled Perl. Yes that's rather a huge guess. I'm assuming that if the each() was in my code which is all pure Perl OR in any number of the CORE/CPAN modules being used would include the filename and the line number if it was loaded and compiled at run time. Is this possible and how can I discover where this is happening? It seems I might need to start digging under the hood again and have a Perl with debugging enabled. That sounds real ugly.

The following is not useful except for causing Perl to burp a lot

#!/usr/bin/env perl use strict; use warnings; EXAMPLE: { my $happy_camper = { Rambler => 'The Yellow Rose of Texas', Wagon => 'There may be flies on them there guys but there ar +e no flies on us', Caskit => 'The Rain in Spain goes mainly down the drain', Skate => 'The Quick Brown Fox Jumped Over The Lazy Dogs Back +', Lemon => 'Love the smell of napalm in the morning' }; my $newkeys = 'KEYME000'; foreach ( 1 .. 900000 ) { while ( my ( $_key , $_val ) = each % $happy_camper ) { if ( int(rand 300000) == 1 ) { # printf STDERR "# Adding new item\n"; $happy_camper->{ ++$newkeys } = 'Shame on you!'; #( keys % $happy_camper )[ int(rand scalar keys % $happy_cam +per ) ]; } } # if (( int rand 2000 ) == 0 ) # { # foreach my $_key ( sort keys % $happy_camper ) # { # printf "# %-12s ->> %s\n", $_key, $happy_camper->{ $_key }; # } # } } } exit 0; ## END

In reply to To each() their own by Ancient.Wizard

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.