I suppose it has to do with the scoping of the warnings module, which is block scoped (i.e. scoped to the "main" program in your case, which is just "1"). Apparently, the x ("evaluate and print expression") command of the debugger is executed in a different block/scope - at least that's my first guess without having looked too deeply into the issue...

If you use the globally scoped -w in place of -Mwarnings, you do get warnings even for x in the debugger, because you then get warnings everywhere (which might be more than you wanted to know, however...)

$ perl -w -Mstrict -de 1 Loading DB routines from perl5db.pl version 1.28 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(-e:1): 1 DB<1> x { foo => () } Odd number of elements in anonymous hash at (eval 5)[/usr/lib/perl5/5. +8.8/perl5db.pl:628] line 2. at (eval 5)[/usr/lib/perl5/5.8.8/perl5db.pl:628] line 2 eval '($@, $!, $^E, $,, $/, $\\, $^W) = @saved;package main; $ +^D = $^D | $DB::db_stop; { foo => () }; ;' called at /usr/lib/perl5/5.8.8/perl5db.pl line 628 DB::eval called at /usr/lib/perl5/5.8.8/perl5db.pl line 3412 DB::DB called at -e line 1 0 HASH(0x65f420) 'foo' => undef

I doubt that this observation is sufficient to entitle me for a free drink of my choice - but anyway. :)


In reply to Re: warnings under the debugger by almut
in thread warnings under the debugger by trwww

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.