Beast wrote: > #!/usr/bin/perl > use strict; > > my $log = '/non/existence/dir/test.log'; > my $msg = "test"; > &write_log($msg); > > sub write_log { > my $msg = shift; > open LOG, ">>$log" || die "Can't write to $log: $!\n"; > print LOG $msg; > close LOG; > } > > --- > > It doesn't die or print any error even $log did not exist. > why?
The || operator has higher precedence so: ">>$log" || die "Can't write to $log: $!\n" is evaluated first and the result of that expression (">>$log") is the file name that is opened. perldoc perlop perldoc perlopentut John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>