In order to answer the question, we must first analyze it. First of all, what is meant by God being perfect? Just because someone says that "God is perfect" and that certain conditions shouldn't exist, does not mean that it is correct. God's perfection deals with his character, not how we think he ought to behave like not allow pain and suffering. There is nothing in the teaching of God's perfection that means he cannot allow us to suffer the consequences of our sinful actions which lead to pain and suffering.
But, the question is about God creating an imperfect world if he is perfect. How is that possible? Well, when we say that God is perfect in his character, we are saying that there are no flaws within him, that he is perfect in his wisdom, complete in his knowledge, and holy in his essence. But these characteristics belong to his nature, not creation. Creation, such as the stars, the planets, the earth, the animals, and people do not possess the same quality of perfection that God does. Just because God is perfect does not mean that his creation must retain the same type of perfection that is his nature.
Furthermore, God created the world, and it was very good as is represented in the Garden of Eden. There was no sin. There was no suffering. And, there was no pain. It was not until Adam and Eve freely chose to rebel against God, that pain and suffering entered into the world. He did not force them to do rebel. It was their choice.
But then again, people ask why Adam and Eve chose to rebel against God since God created them to be perfect. But, the Bible does not say they were "perfect." The Bible says, "God saw all that He had made, and behold, it was very good," (Genesis 1:31). Goodness is not the same thing as God's perfection, and since we see that Adam and Eve were able to rebel against God within their goodness, we can see that they did not have that characteristic of God of absolute perfection.
So, God created a world that was without sin. It was good. He was able to do this because God is perfect, holy, all-knowing, righteous, etc.. But this perfection is a quality of God's existence alone, not that of creation. Therefore, what he created was good (Genesis 1:31), not perfect in the same sense that God is perfect. Furthermore, Adam and Eve had the ability to act freely within their goodness since they were made in the image of God (Genesis 1:26). And, since they are the ones who rebelled, sin entered the world through their actions. To be more specific, sin entered the world through Adam (Romans 5:12) since Adam was the federal head of mankind, not Eve.
Therefore we would say that God allowed Adam and Eve the freedom to rebel and in so doing, pain-and-suffering entered the world. So, in God's perfection, he allowed pain-and-suffering. His perfection does not negate its existence.