[EMAIL PROTECTED] wrote:

From: "John W. Krahn" <[EMAIL PROTECTED]>
This should be close to what you want: my %data;
 while ( <FILE> ) {
      chomp;
      for ( map [ split /=/ ], ( split /\s*,\s*/ )[ 0, -1 ] ) {
          $data{ $_->[ 0 ] }{ $_->[ 1 ] }++;
          }
      }
for my $type ( keys %data ) {
      print "Duplicate $type\n";
      for my $key ( keys %{ $data{ $type } } ) {
          print "$key\n" if $data{ $type }{ $key } > 1;
          }
      print "\n";
      }

I haven't seen hash used in this format. $data{ $val1 }{ $val2 }++; Can yor please tell what this means?

It is called a "Hash of Hashes" and is explained in:

perldoc perldsc

The hash %data stores keys and the values for those keys are a reference to a hash and the values for that hash are autovivified and incremented using the autoincrement operator.

Also, other related documentation:

perldoc perllol
perldoc perlreftut
perldoc perlref


John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to