I understand that the eq and gt are for string comparisons but why not just
use the mathematical ones of == or >.
Because we want Perl to magically convert our variables to whatever we currently mean (number or string) without making us jump through hoops like "casting" them. The only way that's possible is if Perl knows what we currently mean. Operators like + and . are pretty easy to infer meaning from, but when we ask "is this the same as this" Perl need to know how we're comparing since 0.0 ne 0 but 0.0 == 0.
This goes for functions open ... or compared to open .. ||
or vs. || is all about precedence. We want that "or die" part at the end to happen dead last, so we need a super low precedence operator (or). With a higher precedence operator (||) Perl thinks we mean "use this or this as the last parameter to open()". Since the last parameter is usually going to be a true string, the die never gets called and even if it did, it wouldn't be under the right circumstances. If you use parenthesis around open()'s parameters, the confusion is removed and you may use whichever you prefer.
As an added perk:
open FILE, 'some_file.txt' or die "File error: $!";
is clean and reads pretty much like English. Some of us geeks like that.
James
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>