in reply to Increment

You forgot your closing </code> tag.

use strict; my $drive; my $count = -1; open( LIST, "tpconfig -l|" ) or die $!; while( <LIST> ) # I added the <LIST>... which I suspect you had. { ($drive) = unpack '@0 A8',$_; ++$count if m/^drive/; system("tpconfig -delete -drive -index ${count}"); # You should check all system calls for error. # system will set $? to an error code for you. }
As for your errors... they don't look Perl related. Perhaps there is some other reason that you can't delete a drive... like some process has some kind of lock on a file in the drive.

Update: You can read up on $? here

Another Update: raj8 says the script deletes the drives, but still generates the errors.
The "problem" is that system doesn't capture STDERR. The way to circumvent this is to redirect to nul: BUT BEWARE! This will hide ALL error messages from the system call!
Try this:

system("tpconfig -delete -drive -index ${count} 2>nul:"); die "Unknown Error with tpconfig $count" if $? >> 8;
Also, be sure to read chromatic's post. He raises a good point about when you make the system call, although I suspect that since there are only two robots and four errors that this isn't the complete answer. (Although I would bet good money that it does explain the duplicity of the index 0 error).

Replies are listed 'Best First'.
RE: Re: Increment
by raj8 (Sexton) on Sep 06, 2000 at 06:37 UTC
    Correct--this index 0 is hard to crack... Here is the output of $count:
    1 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33