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

Hi Monks!
I have an issue on this line of code I am working on:
my $prefix = ($sql_tablet->[0]{ ACCOUNT } == 1) ? 'BR' : 'US';

Is necessary to have quotes around { ACCOUNT } == '1') or there is no need since the == sign already indicates equality. I know that the value stored in the DB could be 1 or 2.
Thanks!

Replies are listed 'Best First'.
Re: Quote or not to quote, my question!
by ikegami (Patriarch) on Jun 16, 2010 at 19:01 UTC

    '1' creates a string constant.
    1 creates a number constant.

    Since == requires numbers, it's clearer if you actually give it a number. If you don't, it'll still work because whatever you pass to it will get converted into a number.

Re: Quote or not to quote, my question!
by almut (Canon) on Jun 16, 2010 at 18:56 UTC

    There is no need to quote the 1, as == tests numeric equality, and 1 is a number (while '1' is a string).