Here's the deal with
Matthew 5-7. After the beatitudes and admonishing his listeners to be salt and light, Jesus begins to address the misconceptions about the Law. He begins by saying "I came not to destroy the law but to fulfill it." Making it very clear that He was not anti-Law, because He is about to shatter conventional wisdom about the Law.
The Pharisees taught that one could achieve righteousness through obedience to the Law---which is true. The problem was they actually believed that one through hard work and discipline could achieve righteousness. Therefore they had interpretations of the Law that were accomodating to their weaknesses.
The Law said a man could divorce his wife for uncleanness. The Pharisees taught that if a man didn't like his wife's cooking he could consider her an unclean wife and divorce her. Therefore if a man divorced his wife and remarried, according to Jesus, he is committing adultery because "uncleanness" didn't mean what they said it did.
Jesus sayd "you have heard it said...but I say to you..." He is contrasting what the religious leaders said was true with what He said is true of the Law. Saying that "if you look upon a woman and lust..." He is pointing out the universality of mankind's sinful state. "Be ye perfect" is not a NT command, as if wee could achieve that. No, the statement "be ye perfect" is in reference to the demand that the Law makes. The Law demands perfectio.
Which brings us back to Christ's original statement about fulfilling the Law. He was the spotless lamb, the perfect sacrifice. He met the expectation for perfection the Law required, thus making Himself the perfect sacrifice.
We are made perfect in Him. Saving faith and trusting Jesus for our perfection takes the pressure off of any of us to strive for perfect obedience. I strive to keep trusting Him and believing Him for my salvation.