Now, I know (through experimentation) that if I do: perl -wde 0 ...I've got the warnings.

Then you didn't do enough experimenting. ;)

> perl -we "print 0+'abc'" Argument "abc" isn't numeric in addition (+) at -e line 1. 0 > perl -wde 0 DB<1> print 0+'abc' 0
But then your example surprised me because I had assumed that the debugger never gave me warnings for code entered at the command prompt.

So I experimented further and decided that you can get run-time warnings but not compile-time warnings for code entered at the debuger's command prompt.

But back to your real question...

The debuger runs your code using eval (how else?). So your example code ends up being closer to this:

eval "use strict;"; eval "use warnings;"; eval "print undef;"; eval 'print $x[undef];';
and pragmas obey scope so it makes sense (to me, at least) that use warnings and use strict don't do much good in the above code.

I was going to suggest that you make a file e.pm:

use strict; use warnings; 1
so you could do:
perl -de 0 DB<1> use e; print $x[undef]
but that doesn't do any good.

But that reminds me! How do you make pragma magic creep up an extra level of scope? I know how to do this with modules that export symbols. Sometimes it'd be nice to do that with pragmas as well.

        - tye (but my friends call me "Tye")

In reply to (tye)Re: Debugger, use strict, use warnings by tye
in thread Debugger, use strict, use warnings by Coleoid

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.