Hacker News new | ask | show | jobs
by thedufer 4854 days ago
What's wrong with

    $fh = open() || die("File did not open")
? The only difference is that the results of `die` are assigned to `$fh`, but I don't think `die` even returns. It still short-circuits.
2 comments

Nothing is wrong with that. However the actual Perl open() would be like this...

  open my $fh, '<', 'file.txt'  or die "file.txt not found";

  open(my $fh, '<', 'file.txt') || die 'file.txt not found';
Above two lines are equivalent.
Maybe not in this specific instance, but both operators have different behaviour and different uses.