in reply to A question about method return values and error checking
Assuming you are dealing with 5.10.0 or later (I think), the Logical Defined Or actually gives a very elegant way of writing your case, and makes undef a preferred choice:
or evenprintf "Operating System: %s\n", $os->name( long => 1 ) // 'undef';
printf "Operating System: %s\n", $os->name( long => 1 ) // (`uname -o +-r` =~ s/\n//r);
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: A question about method return values and error checking
by wee (Scribe) on Nov 04, 2015 at 21:56 UTC | |
by kennethk (Abbot) on Nov 05, 2015 at 01:51 UTC |