in reply to Elements added to hash in for loop

try including parens
my ($current_id) = @_;

otherwise you are using the length of @_ as key and autovivification creates new entries.

Cheers Rolf

( addicted to the Perl Programming Language)

Replies are listed 'Best First'.
Re^2: Elements added to hash in for loop
by AnomalousMonk (Archbishop) on Dec 13, 2013 at 10:59 UTC
    ... you are using the length of @_ as key ...

    nathaniels: This raises the question: Under what circumstances are you calling the  next_clauseid() function with zero parameters?!?

    I hope that you  usewarnings   so that if you employ the common parameter passing conventions advised by LanX and 2teez, you will at least receive a warning message from Perl in case of such a lapse.

      I'm not nathaniels, but ...

      > I hope that you use warnings so that if you employ the common parameter passing ... you will at least receive a warning message from Perl in case of such a lapse.

      which warning?

      DB<102> use warnings;use strict; sub tst { my $scalar=@_; print $sca +lar } DB<103>

      =)

      Cheers Rolf

      ( addicted to the Perl Programming Language)

        >perl -le "use warnings; use strict; sub tst { my ($scalar) = @_; print $scala +r } tst " Use of uninitialized value $scalar in print at -e line 1.

        That warning :)

      Where can I find these conventions?

        The replies of LanX and 2teez in this thread pretty much say it all. But take a look at what perlsub has to say about parameter passing (in various sections), and at the Function Parameters sub-section in chromatic's very good Modern Perl (chromatic's user node has a link to a free download link).

Re^2: Elements added to hash in for loop
by nathaniels (Acolyte) on Dec 13, 2013 at 04:27 UTC
    I knew it had to be something simple! Thanks for your help!