#!/usr/bin/perl -w use Data::Dumper; my $data; while(<>) { while (m!([A-Za-z_0-9]+)=([A-Za-z_0-9]+)!g) { $data->{$1}{$2}++ } } for my $v (keys %$data) { print "$v: ...\n"; for my $w (keys %{$data->{$v}}) { print "$v=$w: ...\n" } print "\n" }