too tough for me (Verify this number)



BW1234561 ---> this number is mathematically correct

i need a script to verify this string of letters and numbers

step 1: this must start with an "a" or a "b" as in the example above (the second letter can be anything)

step 2: Add the 1st, 3rd, and 5th numbers (example = 9)

step 3: Add the 2nd, 4th, and 6th numbers (example = 12)

step 4: Add the results (example = 9 + 12 = 21)

step 5: The 7th number (in the example) is the last digit of the sum of step 4 (the answer is "1" as in "21")

leaving you a result of ---BW1234561

please help (if there is any confusion please let me know)
Use the substr function.

This is how you can check the first letter is A or B

if ($num{0} == "A" || $num{0} == "B")

Where $num = BW1234561