Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Re: Re: Simplifying code (Not obfuscation)

by zakb (Pilgrim)
on Mar 04, 2003 at 11:29 UTC ( #240294=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://240294]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2020-11-30 05:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?