in reply to unless vs. bare block

chayashida:

If you don't care what you return, you can simplify it a bit like this:

open(QTREES,$file1) or return print "foo";

If you do care, then you can use:

open(QTREES,$file1) or (print "foo") && return;

Example:

$ touch file1; touch file2 $ perl blenge.pl $ rm file2; perl blenge.pl Error opening file2: No such file or directory $ rm file1; perl blenge.pl Error opening file1: No such file or directory $ cat blenge.pl #!/usr/bin/perl use strict; doit(); sub doit { open QTREES, 'file1' or return print STDERR "Error opening file1: +$!"; open RTREES, 'file2' or (print STDERR "Error opening file2: $!") & +& return; }

...roboticus

When your only tool is a hammer, all problems look like your thumb.