use strict; use warnings; my $str1 = q{CHARLIE ROOT}; my $str2 = q{HARRY NODE}; my $output = process( $str1, $str2 ) . q{ } . process( $str2, $str1 ); print $output, qq{\n}; sub process { my ( $word1, $word2 ) = @_; my @letters_to_remove = grep{ ! m/\s+/; } split //, $word2; my $remove_str = join q{}, q{[}, @letters_to_remove, q{]}; my $result = $word1; $result =~ s/$remove_str//g; return $result; } #### CLI T Y ND