On May 30, Peter Cornelius said:
>> if (@ARGV and -T $ARGV[0]) { ... }
>
>Just wondering if there is a reason for using the lower precedence 'and'
>here instead of '&&'? I haven't been finding many uses for 'and' which
>tells me I might not fully understand it.
You must be careful about using operators like '&&' and their
lower-precedence companions like 'and'. I tend to use the spelled out
ones more often, except where it would require machinations to ensure the
proper execution of code:
$x = $foo || $bar; # that's ok
$x = $foo or $bar; # like: ($x = $foo) || $bar
That second case is due to 'or' having lower precedence than '='. You'd
have to do
$x = ($foo or $bar);
It is at that point that I would decide not to use 'or'. On the other
hand, I'd rather do
open FOO, $file or die "...";
instead of
open(FOO, $file) || die "...";
or even worse,
open FOO, $file || die "..."; # like open FOO, ($file || die "...");
I prefer to de-line-noise my programs for readability[1]. As such, I use
parens only where needed.
[1] And yet, I love to use regexes... something for you to discuss among
yourselves, I guess.
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
Are you a Monk? http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
** I need a publisher for my book "Learning Perl's Regular Expressions" **