# note the lower-casing inline ($fus = lc $fus) =~ s/\W+/_/g; #all spans of 1 or more non-words become 1 '_' $fus =~ s/^_|_$//g; #at most one on each end, because of the above #### for ($string) { s/\s+/_/g; #convert 1+ spaces to a single '_' s/'|^_|_$//g; #trim lead/trail _ and remove single quotes } #### $string =~ tr/\s'/_/d;