return $string;
}
-# generates 7 digit number of which digit sum is 7 (e.g.: 4001110)
+# generates 7 digit number divisible by 7
sub generate95_ret_part2 {
- my $sum = shift;
- my $string = "";
-
- for my $i (1..6) {
- my $digit = int(rand($sum + 1));
- $sum -= $digit;
- $string .= $digit;
- }
- $string .= $sum;
-
- return $string;
+ my $num;
+ do {
+ $num = int(rand(9000000)) + 1000000;
+ } while ($num % 7 != 0); # Repeat until the number is divisible by 7
+ return $num;
}
# picks random two digit combination from the list
my $random_index = int(rand(scalar @list));
my $random_value = $list[$random_index];
}
-# generates random 7 digit number, starting with "00"
+
+
+# generates random 7 digit number, starting with "00" and divisible by 7
sub generate95_oem_part3 {
- my $sum = shift;
- my $string = "00";
+ my $string = "00"; # Start with "00"
- for my $i (3..6) {
- my $digit = int(rand($sum + 1));
- $sum -= $digit;
- $string .= $digit;
+ while (1) {
+ my $number = int(rand(90000)) + 10000;
+ if ($number % 7 == 0) {
+ $string .= $number;
+ last;
+ }
}
- $string .= $sum;
return $string;
}
my $result95_oem =
$result95_oem_part1 .
$result95_oem_part2 .
- "-dpo-" .
+ "-OEM-" .
$result95_oem_part3 .
"-" .
$result95_oem_part4;