I need, for testing purposes, to generate some valid, random ABNs (Australian Business Numbers).
The following are some links I was able to find that discuss how to validate an ABN, but it's not really clear to me how to generate values.
skorks.com/2011/08/even-boring-form-data-can-be-interesting-for-a-developer
ato.gov.au/businesses/content.aspx?doc=/content/13187.htm
search.cpan.org/~adamk/Business-AU-ABN-1.09/lib/Business/AU/ABN.pm
Without knowing anything about it, you can just brute force it. This is fine if it's a one-time fixture generation. Not knowing if there is any convention for test numbers, you have to assume many of those generated are likely to represent real business entities.
use strictures;
use Business::AU::ABN "validate_abn";
my $desired = 10; # 1_000;
my $abn = 12_004_044_937; # Example from BAA Pod.
my @abn;
until ( not $desired )
{
next unless my $valid = validate_abn( $abn++ );
$desired--;
push @abn, $valid;
}
print join($/, @abn), $/;
__END__
12 004 044 937
12 004 044 969
12 004 045 391
12 004 045 440
12 004 045 472
12 004 045 521
12 004 045 553
12 004 045 585
12 004 045 602
12 004 045 634