drive 0 dirve 1 drive 2 drive 3 I am using this: open(LIST,"list -l|"); while() { ($drive) = unpack '@0 A3',$_; if(/Drive/) { $count++; } system("list -delete -dr -index ${count}"); }; However, when it gets to 3 it says can't delete 4 because the $i++ started at 1 instead of 0.