kprasanna_79 has asked for the wisdom of the Perl Monks concerning the following question:

my @list_accounts = map { {account => $_->name,id=>$_->account_id} }@a +ccounts; foreach my $list_account (@list_accounts) { $$list_account{account_selected} = ($$list_account{id} == $contacts->account_id) ? 1:0; }
Here i create an anonymous hash and
1. i assign string and an integer. But a warning throws at log
saying that u cant use '==' for string(id).
But it is actually a integer. How to solve it..

--s,,QSBTBOOB,s,y,B-Y,A-Z,d&&print

Replies are listed 'Best First'.
Re: Anonymous hash warning
by borisz (Canon) on Jan 28, 2005 at 12:39 UTC
    print $$list_account{id} and $contacts->account_id. I bet you see one of them is not a integer sometimes.
    Boris
Re: Anonymous hash warning
by r34d0nl1 (Pilgrim) on Jan 28, 2005 at 12:51 UTC
    Pls, create a dumper of the variables you are using.
    Would be easier to try to identify what is happening once that perl is smart enough
    to find when a variable is an in integer or string context.
      Hai r34d0n11
      i am sure its integer, still perl doesnt allow me to use '=='
      to compare values in this case only.

        What exactly to you mean when you say:

        perl doesnt allow me to use '==' to compare values in this case only.

        What exactly did you ask perl to do and what exactly did it say in response.

        What do you mean it in the phrase:

        i am sure its integer

        Do you mean "id" (as in the two chaacter string consisting of the letter 'i' and the letter 'd')? That's not an integer.

Re: Anonymous hash warning
by tphyahoo (Vicar) on Jan 28, 2005 at 12:38 UTC
    Hi!

    Tip: Put <code> tags around your code.

    This will make PerlMonks render them in a monospaced font and allow your code to be easily extracted.

    Writeup Formatting Tips

    UPDATE: Guess I should have suggested this with chatterbox via /msg.