#!/usr/bin/perl use strict; use warnings; my @array; open(my $fh,"<","file3") or die "Failed to open file: $!\n"; while(<$fh>) { chomp; push @array,$_; } close $fh; foreach my $line(@array) { if($line =~ /.*([0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]).*logged in\((.*)\).*/gi) { print $1,",$2,"\n"; } }
example file: file3
com.cn.dat.2015-04-03.log.ms.com logged in(fengcx)stack.over com.cn.dat.2015-04-05.log.ms.com logged in(mike)this.is com.cn.dat.2015-04-05.log.ms.com (mike)this.is
@H_404_26@