while () { chomp; my @pieces = grep /[a-z]/i, split /[()]+/; printf( "Got %d pieces from '%s' : %s\n", scalar @pieces, $_, join( ' and ', @pieces )); } __DATA__ (network)(test)(ifcfg) (network) (test)_(ifcfg) (foo).(bar) (one)(two)--(three)/(four),(five)