my @VERSES,$longline; while(){ chomp; # remove newlines next unless $_; # no empty lines? # check if a newline is required s/(\d+:\d+)/\n${1}/; # make lines end in space (separate words) s/\s?$/ /; $longline .= $_; } @VERSES = split(/\n/, $longline); for my $verse (@VERSES){ # remove verse number from verse $verse=~s/(\d+:\d+)\s*//; my $versenumber = $1; print "# verse $versenumber #\n"; my @phrases = split(/\s*[,.;:]\s*/, $verse); for my $phrase (@phrases){ $_ = uc($phrase); # uppercase tr/0123456789/0000000000/; tr/ABCDEFGHIJKLMNOPQRSTUVWXYZ/12345678912345678912345678/; my $value = 0; $value += $_ for(split(//)); # sum print "TXT:$phrase\nNRX:$_ = $value\n"; } } __DATA__ 3:3 And he shall offer of the sacrifice of the peace offering an offering made by fire unto the LORD; the fat that covereth the inwards, and all the fat that is upon the inwards, 3:4 And the two kidneys, and the fat that is on them, which is by the flanks, and the caul above the liver, with the kidneys, it shall he take away. 3:5 And Aaron's sons shall burn it on the altar upon the burnt sacrifice, which is upon the wood that is on the fire: it is an offering made by fire, of a sweet savour unto the LORD.