$/ = '.$/; my $prev_rec=''; while () { next if ($_ eq $prev_rec); $prev_rec = $_; # process $_ somehow as it is unique } #### use Data::Dumper; if (Dumper(\%struct1) eq Dumper(\%struct2)) { do something; }