in reply to Re: numeric hash keys
in thread numeric hash keys

sorry I added the int($PM) to try and fix the problem but it didn't work. I get the same error without the int($PM) line. if I use <= in the if statement then why doesn't it treat the keys like a number?

Replies are listed 'Best First'.
Re^3: numeric hash keys
by Corion (Patriarch) on Mar 06, 2015 at 14:08 UTC

    Please re-read our replies.

    When you use a value in numeric context, for example by using the <= operator on it, Perl expects a number. But you are handing it something else. Perl even tells you what it saw instead, but you seem to hide that value from us.

    Find out what the offending value is and then look at your code and think about how that value gets there.

    Most likely, printing $PM and thinking long and hard about the difference between what you expect in $PM and what you get might give you a hint.

Re^3: numeric hash keys
by Anonymous Monk on Mar 06, 2015 at 14:04 UTC
    I get the same error without the int($PM) line.

    No, you don't - the error message will be different. Please provide the exact error messages and the exact code used to produce them.

    You've also edited your original post without marking it updated. Don't do that, see here for why.

    why doesn't it treat the keys like a number?

    If $PM is "parent mass", how do you expect Perl to use that as a number?

    I suspect your problem is in the input data.

    Please read and follow How do I post a question effectively? - please show the exact code used, the exact error message, and the exact sample input used to generate that error.