in reply to Strange bevahiour of grep function.
You don't need the test of $_mnum_prevVal in the grep as it never changes (it doesn't refer to $_), so you can move that outside the grep and that might make things easier.
In Section
Seekers of Perl Wisdom