#!/usr/bin/perl use strict; use warnings; #use diagnostics; my $file = "c:\\tmp.txt"; open( my $fh, "<", $file ) or die $!; my $OUTNET = "c:\\NETtmp.txt"; open( OUTPUT, ">", "$OUTNET" ) or die $!; my @array; foreach (<$fh>) { chomp ; if ( $_ =~ m/^\s+\d/ ) { $_ =~ s/^\s+//g; $_ =~ s/\s+$//g; $_ =~ s/\s+/,/g; push @array, "s_"; print " $_ \n"; printf OUTPUT "$_ \n"; } } close OUTPUT; my $file2 = "c:\\NETtmp.txt"; my $OUTNET2 = "c:\\final.txt"; open my $in, '<', $file2 or die $!; open my $out, '>', $OUTNET2 or die $!; seek $in, 0, 0; my %hash; while (<$in>) { my $key = join ',', ( split /,/ )[ 1, 2, 3, 4 ]; printf $out $_ unless $hash{$key}++; } close $out; close $in;