mojodaddy has asked for the wisdom of the Perl Monks concerning the following question:

I was getting a silly warning from WWW::Mechanize about finding <input> tags outside <form> tags (silly because it was wrong; I checked the HTML and all the inputs were inside the form tags, just as they should be). The warning was emanating from the HTML::Form module, which appears from the documentation to have a 'verbose' option, but I couldn't see how Mechanize was passing it, unless it is on by default, though the doc seems to suggest otherwise.

Suffice to say that after great gnashing of teeth / rending of garments, etc. I succeeded in making the warning go away by reinstalling the entire LWP library!

Still, I'm baffled by the things I tried that didn't work, including:

So, like, what gives?

Because I was under the impression that 'use warnings' was like an on-off switch. If it's on, you'll see warnings; otherwise not. And I liked that, because it meant I could file it under "things about perl I understand" and get back to figuring out the stuff I didn't (i.e. pretty much everything else). Only now I have to pull it out of the "things I understand" category and put it back in the "unfathomable mystery" category with all its friends! My learning curve, which has been like a straight vertical line for the past several weeks, has apparently toppled over backwards.

Can anyone shed a little light? One theory I have is that the message I was seeing wasn't a "warning" exactly; If not, what was it then? And why did reinstalling LWP make it go away? And why was I getting it in the first place when the HTML was OK? (I have perl 5.8.7 on a debian-based platform, in case it matters.)

Thanks all.

  • Comment on Things I don't understand about 'use warnings'

Replies are listed 'Best First'.
Re: Things I don't understand about 'use warnings'
by Fletch (Bishop) on Mar 27, 2007 at 23:35 UTC

    You're confused about the function of the warnings pragma versus possible warning output from a particular module. The former controls diagnostic output and what not from Perl itself; the latter is controlled (usually) by some sort of option either passed to a constructor or the like (maybe setting a package varialbe). While it's conceivable for a module to look at $^W in order to enable or disable its diagnostics it's not common.

    As for why reinstalling fixed, unless you're sure you installed the same versions it's possible you picked up a version that corrected a bug, or perhaps turned off whatever was causing the diagnostic you were seeing.

      Sweet! Thanks for that.

      Boy, a bug, huh? You mean my pitiful lack of knowledge and skills isn't the only reason I can't get things to work? : )

Re: Things I don't understand about 'use warnings'
by friedo (Prior) on Mar 28, 2007 at 00:28 UTC

    As Fletch notes, turning off use warnings; won't suppress things emitted via warn or carp.

    However, if you want your warn statements to respect lexically scoped warnings, you can use warnings::warnif instead.