http://qs321.pair.com?node_id=240294


in reply to Re: Re: Simplifying code (Not obfuscation)
in thread Simplifying code (Not obfuscation)

Well for me, maintainability should be one of our highest concerns as developers: will the developer who follows me understand my code? But that's probably a good subject for a meditation later!

You're close with catching the error; this should work:

$var = `...` or die "System failed: $!\n";

Basically, you don't need the if; the left hand side of the expression will be undef (false) if it fails, so the or will evaluate the right hand side. You'll see this form of error catching quite a bit, especially when using open and the like to operate on files. Note the use of $!, which will tell you what the system error message was - see perlvar for more information about this.