while(){ $in = $_; @txt = chop($in); for my $line (@txt) { my @cn = $line =~ /cn=(\w+),/g; print Dumper \@cn; } }