my($first, $second, $third) = $text =~ /(\([a-z]*\))(?:\s|_|$)/gi; print "$first and $second and $third\n"; #### no warnings 'uninitialized'; my $count = $text =~ s/(\([a-z]*\))(?:\s|_|$)/$1$2/gi; print $count; use warnings; #### (network) and (test) and (ifcfg) 3