sub stripPOS { my $words = shift; # rip out any / plus following characters, up to the # first space $words =~ s!/\S*!!g; return $words; } $sentence =~ s! \s \ (.*?) \ \s ! stripPOS($1). '/NP' !egx; #### The/D best/A one/N of/P the/D Perl/N Monks/N