use strict; use warnings; use lib "/Library/Perl/5.10.0/"; use autodie; open FILE, "<", "data/04102013_loginlogs.txt" or die "Cannot open input file.\n"; open OUT, ">>", "output.txt" or die "Cannot open output file.\n"; my %found; while( my $line= ) { $found{$1}++ if( $line =~ /unknown type\(0x134e\)\s+30\.6511\s+\(V6\.5\.1 FP1\)\s+(.*)\s+\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\s*$/ ); } print join( "|", keys %found), "\n"; close OUT; close FILE;