while() { my @x = split /,|\^`/; next unless ($x[4] =~ /560/); #we only want the files with 560 print join("\n",@x), "\n"; # debugging print line - remove in production unless($x[16] =~ /Primary User Name: CISERFS1/) { #only match this case print OUTPUT "$x[1] $x[2] $x[12] $x[16] \n"; # or whatever } # unless } # while