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

Esteemed monks,

I've installed Strawberry Perl on my Windows 7 machine and was able to successfully install both PAR::Packer and Net::SNMP (with the intent of packing snmpenum.pl into a stand-alone executable). However, I then came to the realization that running snmpenum.pl under Strawberry Perl bombards me with the following warning spam: "Use of :locked is deprecated at Net/SNMP.pm line XXXX". The only way I was able to successfully mute this spam was by replacing the "-w" with a "-X" in my initial snmpenum.pl perl declaration line. I was content with this solution until I ran it through pp. The resulting binary that was produced ignored my -X flag and still produced the flurry of warnings. All attempts to suppress this spam beyond the declaration line have failed (I've tried "no warnings", "$^W = 0", and various other warning suppression techniques to no avail)

Does anyone know what is causing this aberrant behavior? In UNIX, the warnings aren't even generated, so I don't need the "-X" flag.
On Windows, the warnings are generated despite the fact it is the exact same version of the Net::SNMP library. However, these can be suppressed with "-X"
On Windows, in a "pp-packed" executable, I've found no way to suppress these warnings.

If anyone could point me in the right direction, it would be much appreciated. Am I missing something glaringly obvious?

  • Comment on Unable to suppress warnings using PAR-Packer on Win32 with Strawberry Perl

Replies are listed 'Best First'.
Re: Unable to suppress warnings using PAR-Packer on Win32 with Strawberry Perl
by ww (Archbishop) on May 19, 2010 at 00:42 UTC

    locked appears more than two dozen times in Net::SNMP. That makes it a bit difficult to offer anything very specific responsive to your characterization of the warning re "line XXXX" as "spam" but have you reviewed the new deprecations in the 5.12 delta?

    The readme.txt in snmpenum.pl does not meet my specs for comprehensiveness. In itself, that script is pretty straightforward, but groking all that's in the 3k+ lines of Net::SNMP is beyond the scope of this reply.

    When you say "...it is the exact same version of the Net::SNMP...." do you mean that the version of the module you're using under Windows is line-for-line identical to that you're using under UNIX (ignoring only \r\n-type variances) or something less global? And are you running with 5.12.n on both the UNIX and the Windows machines?

    Have you explored what happens when you try this (on Windows) with an earlier version of Perl -- say 5.8.n or 5.10.1? See some of the replies to Wow! Painful upgrade to Perl 5.12

    Update:

    Taking my own advice and actively heeding the surmise (below) from syphilis, this answer, from the 5.12 delta, leaps out:

    Potentially Incompatible Changes ^
    Deprecations warn by default

    Over the years, Perl's developers have deprecated a number of language features for a variety of reasons. Perl now defaults to issuing a warning if a deprecated language feature is used. Many of the deprecations Perl now warns you about have been deprecated for many years. You can find a list of what was deprecated in a given release of Perl in the perl5xxdelta.pod file for that release.

    To disable this feature in a given lexical scope, you should use no warnings 'deprecated'; (Emphasis supplied) For information about which language features are deprecated and explanations of various deprecation warnings, please see perldiag.pod.

    And, from perldiag.pod,

    =item Attribute "locked" is deprecated

    (D deprecated) You have used the attributes pragam to modify the "locked" attribute on a code reference. The :locked attribute is obsolete, has had no effect since 5005 threads were removed, and will be removed in the next major release of Perl 5.
      Yes, by "same version", I mean the exact same module installed on both UNIX and Windows -- UNIX does not show the warnings, but Windows does. I have not tried this on Windows with an earlier version of Perl (mainly because that seems like more of a kludge than a fix). But you are correct that the Perl I have installed on UNIX is 5.8 whereas on Windows it is 5.12, which appears to explain the discrepancy there.

      But to the more important point of addressing the warnings...I've already tried "no warnings 'deprecated'" -- that's a subset of "no warnings", which I also tried. The warnings still persist. The only way I've been able to suppress the warnings is with the -X flag, and that doesn't carry over to the packed executable (for an as yet unknown reason). So outside of downgrading to Perl 5.8 or modifying Net::SNMP code, are you aware of any fix?

Re: Unable to suppress warnings using PAR-Packer on Win32 with Strawberry Perl
by syphilis (Archbishop) on May 19, 2010 at 00:54 UTC
    Same thing happens on ActivePerl (5.12.0). I speculate that this is some across-the-board deprecation for perl 5.12.0, and that you'll get the same warnings on *any* OS running perl-5.12.

    If that's so, then it's odd that there's, as yet, no Net::SNMP bug report anout this. It's certainly annoying to be hit with all those warnings whenever Net::SNMP is loaded.

    Cheers,
    Rob
      its seems to be related to 5.12, i didnt see it in 5.10 how can we suppress this warnings? Thanks Adi
        1) read the whole thread 2) apply solution or 3) wait for new Net::SMTP release and install it
Re: Unable to suppress warnings using PAR-Packer on Win32 with Strawberry Perl
by Anonymous Monk on May 18, 2010 at 23:02 UTC
    Can you provide a test case? Because locked returns zero results, and there is no snmpenum.pl
      Not entirely sure what you mean by test case, but here is a link to snmpenum

      It's a simple SNMP scanner.

      I'm running the latest Net::SNMP (version 6.0) and PAR::Packer (1.004), which can be found at CPAN, and the latest Strawberry Perl (5.12.0.1).