in reply to Something is leaking

Those two constants ended up in the output because you used for. I would use unless instead.
#!/usr/bin/perl use strict; use warnings; use SNMP; use Data::Dumper; my $hostname = '127.0.0.1'; my $community = 'DoesNotWork'; $SNMP::verbose = 1; $SNMP::debugging = 1; main(); sub main { my @item =('something that leaks', 'more leaking stuff'); unless (not @item) { doit(); } } sub doit { my $session = new SNMP::Session('DestHost' => $hostname, 'Community' => $community, 'Timeout' => 0, 'Version' => '2c'); my $x = $session->bulkwalk(0, 1, ['.1.3.6.1.2.1.1.1']); warn 'DUMP IT: ' . Dumper(\$x); }

Replies are listed 'Best First'.
Re^2: Something is leaking
by GrandFather (Saint) on Mar 05, 2011 at 20:46 UTC

    What do you think is happening in the OP's code and how does your change fix the problem?

    True laziness is hard work
      I was thinking that the OP wanted a test failure, so I tried reversing the sense of the test to get around the freed value warning. How would you handle it? Thanks for the response.
        I was thinking that the OP wanted a test failure

        Where did you glean that idea from? The OP has obviously reduced a larger piece of code to a simple test case to demonstrate a really bizarre issue. Assuming it runs as advertised, the code does just what the OP wants. The question is: "Why?".

        I tried reversing the sense of the test to get around the freed value warning.

        What freed value warning? The OP used a die statement to show the puzzling result the code produces, but that is not an error or warning, just one of the ways the result could have been shown.

        How would you handle it?

        I looked at the code. Determined I hadn't the SNMP module installed and on Windows that looked like more work than I could be bothered with to install. I couldn't verify the result so I left the question for someone else to answer. dave_the_m's answer seems most likely correct, although I'd have pointed the finger at the more general "corrupting memory" answer.

        If you are unsure of your understanding of a question you should either ask a follow up question (if the OP's question seems unclear) or don't answer if it is an area you are unfamiliar with and can't be bothered researching.

        True laziness is hard work
Re^2: Something is leaking
by mogul (Novice) on Mar 06, 2011 at 06:22 UTC
    No no, my whole point was not to touch or use $item or any of the two constants after their declaration.

    And still they get printed.