in reply to Re: Match first word in line fails
in thread Match first word in line fails

Change this:

my @sentence = split(/\W+/,$line);

to:

my @sentence = split(/(\W+)/,$line);

Now @sentence will contain the punctuation as well.