note
tye
<p>And in the case we are discussing here, <code>||</code> is very much wrong. Consider the first example of
<code>|| die</code> in the posted code:</p>
<code>
mkdir "$dir", 0777 || die "Could not mkdir \"$dir\": $!\n";
</code>
<p>Here is a demonstration of why this is wrong:</p>
<code>
my $dir= "source"; # A directory that I know exists.
warn "Using or...\n";
mkdir "$dir", 0777 or die "Could not mkdir \"$dir\": $!\n";
warn "Using ||...\n";
mkdir "$dir", 0777 || die "Could not mkdir \"$dir\": $!\n";
warn "Done.\n";
</code>
<p>This produces the following output:</p>
<code>
E:\etm\Work>perl -w mkdir.pl
Using or...
Could not mkdir "source": File exists
Using ||...
Done.
</code>
<p>Note that <code>-w</code> was silent as well, so I'm not sure when it will warn me of a precedence problem (I'm using Perl 5.6.0).
</p>
-
<a href="/index.pl?node=tye&lastnode_id=1072">tye</a>
(but my friends call me "Tye")
26921
26932