Short Answer: In context "you are to be perfect" means "you are to love as God loves: without partiality"
First, consider the immediate context:
You have heard that it was said, ‘You shall love your neighbor and hate your enemy.’ But I say to you, love your enemies and pray for those who persecute you, so that you may be sons of your Father who is in heaven; for He causes His sun to rise on the evil and the good, and sends rain on the righteous and the unrighteous. For if you love those who love you, what reward do you have? Do not even the tax collectors do the same? If you greet only your brothers, what more are you doing than others? Do not even the Gentiles do the same? Therefore you are to be perfect, as your heavenly Father is perfect. -Matthew 5:43-48
Here Jesus is clarifying that (despite popular opinion) the intent of God's commandment was for His people to love everyone -- even their enemies. He then goes on to provide evidence that God exhibits this kind of impartial love (by citing His care for the wicked), thereby establishing the basis for His clarification of God's commandment. Jesus then clarifies that the attitude that you will "love those who love you" is nothing special; even the wicked do this. He then concludes with the following:
"Therefore you are to be perfect as your heavenly Father is perfect."
In other words, having just explained how the Father is "perfect," and instructing God's people to behave similarly, He is now concluding with a summary statement.
So the flow of the paragraph could be summarized as follows:
You have heard "love with partiality" but I say to you "love impartially" so you can be sons of the Father; for the Father loves impartially. If you love with partiality, you are nothing special... even the wicked do that. Therefore, you are to love perfectly as the Father loves perfectly.
Answering the critics
Summarizing "perfection" as "love" may be a shock to modern interpreters, but it would not have been to the Apostles. For example, Paul wrote:
Owe nothing to anyone except to love one another; for he who loves his neighbor has fulfilled the law. -Romans 13:8
For the whole Law is fulfilled in one word, in the statement, “You shall love your neighbor as yourself.” -Galatians 5:14
James likewise contrasted partiality with fulfilling the "royal law":
If, however, you are fulfilling the royal law according to the Scripture, “You shall love your neighbor as yourself,” you are doing well. But if you show partiality, you are committing sin and are convicted by the law as transgressors. -James 2:8-9
Jesus Himself clarified that the sign of a true disciple was his love for others:
By this all men will know that you are My disciples, if you have love for one another.” -John 13:35
(The list goes on, but that should suffice for now.)
So it is not hard to see from Scripture that "perfection" (or "completeness" / "maturity"), "fulfilling the Law," and "loving others" are synonymous.