Loading ...
Sorry, an error occurred while loading the content.

RE: [PBML] Incrementing hash value

Expand Messages
  • Charles K. Clarkson
    ... That works for me. What made you think it wasn t working? my %wordcount; my @conlist = foo ; my $conlistpos = 0; $wordcount{ $conlist[ $conlistpos ] }
    Message 1 of 4 , Sep 22, 2004
    • 0 Attachment
      evyn <evan@...> wrote:

      : How do you increment a value in a hash pair? The following
      : does not work:
      :
      : $wc = $wordcount{$conlist[$conlistpos]};
      : $wc++;
      : $wordcount{$conlist[$conlistpos]} = $wc;

      That works for me. What made you think it wasn't
      working?


      my %wordcount;

      my @conlist = 'foo';
      my $conlistpos = 0;

      $wordcount{ $conlist[ $conlistpos ] } = 1;

      print "$wordcount{ $conlist[ $conlistpos ] }\n";

      my $wc = $wordcount{ $conlist[ $conlistpos ] };
      $wc++;
      $wordcount{ $conlist[ $conlistpos ] } = $wc;

      print "$wordcount{ $conlist[ $conlistpos ] }\n";


      HTH,

      Charles K. Clarkson
      --
      Mobile Homes Specialist
      254 968-8328
    Your message has been successfully submitted and would be delivered to recipients shortly.