The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.
I swear to god that's true, and it's been driving me crazy for an hour. Somebody help me!
I swear to god that's true, and it's been driving me crazy for an hour. Somebody help me!
if ("foo" == "bar") {
print "Apparently, foo == bar!!!\n";
}
It's a basic if() clause, the cornerstone of any programming language, yet it's printing out "Apparently, foo == bar!!!", when foo blatently doesn't equal bar! It's absolutely crazy! All I want is PERL to acknowledge that foo does not equal bar!
What have you assigned the variables foo and bar? are they strings? nemerical or some other type?
Maybe something wrong when you assigned the variables, if they are numeric then I think you use the double = but if they are strings I think you need to use eq or equals( ) kind of thing.
I'm not sure if what you posted was the full code you use or if there is more but If you still can't get it let me know, i'll try think some more on it.
Stupid PERL distinguishes betwen "==" (for numerics) and "eq" (for strings). I honestly can't see the point at all. God I hate this language.
> I've got it sorted.
Stupid PERL distinguishes betwen "==" (for
> numerics) and "eq" (for strings). I honestly can't see the point at
> all. God I hate this language.
Simple example
if ("10" == "10.0") {
print "test\n";
}
Returns as true...
if ("10" eq "10.0") {
print "test\n";
}
Returns as false...
Guess that shows the need pretty clearly? String equivalence and numerical equivalence are quite different things hence the need for EQ and NE.
Every language is different, and its easy to hate them at first especially when you're switching from one language to another and the old tricks don't work. They all have their strengths and weaknesses though, in my opinion Perl's string handling is awesome. On the other hand, its syntax leaves something to be desired, pick a character on the keyboard and you can guarantee Perl has some use for it.
But just for the record, I -really- hate Python. :)
-G
There probably is a plausible reason for that distinction, but I can't possibly think of it at the moment. In the last four days I've had less sleep than I usually have in one night.
Perl's extremely powerful but weird in a lot of ways. Deal with it :)