in reply to Associative array

You're using $data_pair as if it were a hash reference (see perlreftut), and you use the correct syntax for that. If you get an undefined warning, maybe the value simply doesn't exist?

Update: changed content. I didn't see the hash ref on first reading.

Replies are listed 'Best First'.
Re^2: Associative array
by gem555 (Acolyte) on Jul 13, 2009 at 06:21 UTC
    the below code prints out the keys and values
    print $data_pair->{'key'}; print $data_pair->{'value'};
      This doesn't print the keys and values, but the values associated with the keys key and value.

      If you want to print the hash out for debugging purposes, use Data::Dumper.

      If you want to access the keys/values in your program, use keys %{$data_pair} or values %{$data_pair} instead.