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.

Replies are listed 'Best First'.
Re: Re: Re: Re: Simplifying code (Not obfuscation)
by 2mths (Beadle) on Mar 04, 2003 at 11:38 UTC
    Fantastic reply!

    Explanation of such things as: Use of if, or and $! greatly appreciated. One of those posts that makes brings together lots of snippets from here and there to create something far greater than the sum of it's parts.

    If I can vote for this reply I will, though it'll have to be tomorrow, my 5 for today have been spent.