use strict; use warnings; my $string = 'Hello (World).'; print join '_', ($string =~ /(\w+)/g); Prints: Hello_World