while ( my $in = ) { chomp $in; my @cn = $in =~ m/cn=(\w+)/g; print Dumper \@cn; }