One might also have translated שָׁלֵם here as "full" or "complete". In the Greek Septuagint, we find the word πλήρης (plērēs), which appears over a dozen times in the New Testament and is translated everywhere as "full" in the King James Version. The New JPS Tanakh - a Jewish translation - uses the phrase "wholehearted" here:
For the eyes of the LORD range over the entire earth, to give support to those who are wholeheartedly with Him. You have acted foolishly in this matter, and henceforth you will be beset by wars
Another Jewish translation puts it:
For the Lord-His eyes run to and fro throughout the entire earth to grant strength with those whose heart is whole toward Him. You have dealt foolishly in this matter, for from now on you shall have wars
I think we might also recall here:
You shall love the LORD your God with all your heart and with all your soul and with all your might (Deuteronomy 6:5; also Matthew
22:37 and Mark 12:30)
where the same Hebrew word לֵבָב (lïbab - "heart") appears.
So we are sort of recasting your question from "How does one get our heart perfect toward God" to "How does one love God with one's whole heart?" The Christian view of this question should be, I think, that such a thing is possible, since (1) the Lord commanded us to be perfect (Matthew 5:48) and we do not think He would have commanded us to do something we could not; and (2) not obeying such a clear commandment would certainly fall short of perfection.
John Climacus1 wrote, "He who has come to know himself has obtained an understanding of the fear of the Lord; and he who has walked by the aid of this fear, has reached the door of love."2 The key to this self-knowledge, as he writes elsewhere, is humility:
Humility is a divine shelter to prevent us from seeing our
achievements. Humility is an abyss of self-abasement, inaccessible to
any thief. Humility is a tower of strength against the face of the
enemy (Psalm 60:3 LXX). No advantage shall his enemy have over him,
nor shall the son, or rather the thought, of iniquity avail to hurt
him any more, but he will hew down his enemies before his face, and
them that hate him shall be put to flight (Psalm 88:23 LXX).
You will know in yourself and not be lead astray that you have this
holy possession within you by an abundance of unspeakable light, by an
unutterable love for prayer; and before this is attained, by a heart
that does not judge the fault of others. And the precursor of what
has been said is hatred of all vainglory.
He who has come to know himself by discerning each feeling of his soul
has sown on earth; but those who have not thus sown cannot expect
humility to blossom forth.3
The above might remind us of another teaching of the Lord: Blessed are the pure of heart, for they shall see God (Matthew 5:8). Follow peace with all men, and holiness, wrote the writer of Hebrews, without which no man shall see the Lord (Hebrews 12:14)
1. 579-640 AD. He was abbot of the Orthodox Monastery of St. Catherine's in Sinai, where 12 centuries later Tischendorf would abscond with the Codex Sinaiticus. Today the librarian of St. Catherine's is actually an American monk from El Paso, Texas - Archimandrite Justin Sinaites. He gives a talk here on the history of the monastery.
2. The Ladder of Divine Ascent, 25.29
3. Ibid., 25.26-28