#!/usr/bin/perl my $sen = ; chomp $sen; if($sen =~ s/(\.|\?|\!)$/ /g){ #get punctuation and replace with whitespace $punctuation = $&; } while($sen =~ m/ /g){ # test for spaces in sentence my $pos = pos $sen; my $element = substr($sen,0,$pos,""); # get chunk of sentence chop $element; #remove end whitespace push(@senElements,$element); #push chunk into array } open(NOUNS,'<',"nouns.txt") or die "Can't open noun database: $!\n"; # # # attempt to recognize sentence elements as a noun via file nouns.txt # # # foreach $element (@senElements){ while(){ chomp(my $line = $_); $line =~ s/ |\n//g; #remove any space chars and newlines from file line if($element =~ m/^($line)$/i){ print "\n!MATCH! ~ $element is a noun\n"; } } } close(NOUNS);