# make sure /tmp/unlocked_[ab] exist first if ($write_to_A) { lock_region { print "Writing to Drive A ...\n"; ## do A stuff print "Done with Drive A.\n"; } qw(/tmp/unlocked_a /tmp/locked_a); } else { lock_region { print "Writing to Drive B ...\n"; ## do B stuff print "Done with Drive B.\n"; } qw(/tmp/unlocked_b /tmp/locked_b); }