Hello, and thanks for writing in.
It sounds like you are describing tapeworm segments. Tapeworms are long and made of many segments, but they will pass out of the anus usually one segment at a time. They can be anywhere from sesame seed size to grain of rice size. This is something that you need to get medication from your veterinarian to get rid of. Usually treatment is in the form of an injectable medication, or an oral dewormer called Drontal. Most deworming medications will not get rid of tapeworms, that is why you will need a special dewormer from your veterinarian.
You can read a good article on tapeworms HERE.
I hope this helps.