|XP is just a number|
System and a question of styleby D.Millin (Beadle)
|on Feb 07, 2003 at 00:49 UTC||Need Help??|
D.Millin has asked for the wisdom of the Perl Monks concerning the following question:
I haven't much experience writting Perl code on Unix, as the company where I work as a Unix administrator only uses the Korn shell, Awk and Sed for everything. For my current project, I have to use Perl :-).As I have never seen or used perl in a system admin role on Unix, I haven't developed my own style. I would value the monks advise on the user of system() and programming style.
In my scripts I need to deport and import volume manger disk groups in order to take a point-in-time copy. Each command must be check to ensure that I get clean copy of the disk group. If I were using the Korn Shell, when I need to check the return code, the code would look something like:
From digging through the Camel book and perldocs, I read that when executing a command using the system function, $? needs to be shifted by eight bytes to get the proper return code. From searching the net, I have seen this implemented in a variety different way, such as:
What I am unsure about is what is then best/efficient way of implementing this. Is it better to carry out the $rc = $_ >> 8; operation after every system call and then check the return code, or would it be better to encase system within the if statement?, and only do the $rc = $_ >> 8; where I absolutely need to use the proper return code.Thanks,