I haven't ran the code myself, but the thing that jumps out to me is a scoping problem. Here's code with that exemplifies this problem:
if (1 == 1) {
my $x = 1;
}
SETVALUE("passin", $x);
This code won't run. Because the variable is initialized inside the "if," it exists only inside of the "if." To fix that code, I would initialize the variable before the "if":
my $x;
if (1 == 1) {
$x = 1;
}
SETVALUE("passin", $x);
So to fix the scope problem in your code, add this before the first "if":
my $vehicleOne = 0;
my $vehicleTwo = 0;
And then remove the "my" from inside the "if" and "elsif" codes.