[San-Diego-pm] A puzzler
David Romano
david.romano at gmail.com
Tue May 2 22:51:56 PDT 2006
Hi Mark,
On 5/2/06, Mark T. Johnson <markj at matzsoft.com> wrote:
> Here's one that has me scratching my head. How can you have 2
> scalars that are eq but not ==? Sample output from perl -d
>
> DB<20> x $deltas{retail}
> 0 2
> DB<21> x $local->{retail}
> 0 2
> DB<22> x $deltas{retail} == $local->{retail}
> 0 ''
> DB<23> x $deltas{retail} eq $local->{retail}
> 0 1
>
> Is it some how treating one as numeric and the other not?
I honestly don't know the solution to your problem. What version are
you using? Here's what I did to try to duplicate the problem:
paperweight:~ dromano$ perl -v; perl -d -e '$local->{retail} = "2";'
-e '$deltas{retail} = "2";' -e '$local->{retail} = 2;' -e
'$deltas{retail} = 2;' -e '$local->{retail} = "2";' -e '1;'
This is perl, v5.8.8 built for darwin-2level
Copyright 1987-2006, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
Loading DB routines from perl5db.pl version 1.28
Editor support available.
Enter h or `h h' for help, or `man perldebug' for more help.
main::(-e:1): $local->{retail} = "2";
DB<1> n
main::(-e:2): $deltas{retail} = "2";
DB<1> n
main::(-e:3): $local->{retail} = 2;
DB<1> x $deltas{retail}
0 2
DB<2> x $local->{retail}
0 2
DB<3> x $deltas{retail} == $local->{retail}
0 1
DB<4> x $deltas{retail} eq $local->{retail}
0 1
DB<5> n
main::(-e:4): $deltas{retail} = 2;
DB<5> x $deltas{retail}
0 2
DB<6> x $local->{retail}
0 2
DB<7> x $deltas{retail} == $local->{retail}
0 1
DB<8> x $deltas{retail} eq $local->{retail}
0 1
DB<9> n
main::(-e:5): $local->{retail} = "2";
DB<9> x $deltas{retail}
0 2
DB<10> x $local->{retail}
0 2
DB<11> x $deltas{retail} == $local->{retail}
0 1
DB<12> x $deltas{retail} eq $local->{retail}
0 1
DB<13> n
main::(-e:6): 1;
DB<13> x $deltas{retail}
0 2
DB<14> x $local->{retail}
0 2
DB<15> x $deltas{retail} == $local->{retail}
0 1
DB<16> x $deltas{retail} eq $local->{retail}
0 1
Can you provide any more context? How are the variables being assigned?
David
More information about the San-Diego-pm
mailing list