Skip to content

Instantly share code, notes, and snippets.

@mattfoster
Created July 17, 2014 09:49
Show Gist options
  • Save mattfoster/4ad5b72cf13697b9bd06 to your computer and use it in GitHub Desktop.
Save mattfoster/4ad5b72cf13697b9bd06 to your computer and use it in GitHub Desktop.
A quick script to generate random client names
#! /usr/bin/env perl
# Generate random client names
use warnings;
use strict;
use Carp qw( croak );
use Readonly;
Readonly my @COMPANY_TYPES => qw( Ltd PLC B.V. S.p.a. LLC LLP Incorporated );
sub random_dictionary_word {
my $dict = shift || '/usr/share/dict/words';
srand;
my $line;
open(my $dict_handle, '<', $dict) or croak "Could not open dictionary $!\n";
rand($.)<1 and ($line=$_) while <$dict_handle>;
close $dict_handle;
chomp $line;
return $line;
}
sub random_company_suffix {
return $COMPANY_TYPES[rand @COMPANY_TYPES];
}
sub random_client_name {
my $words = shift || 2;
my $suffix = shift || 1;
my @name;
while ($words) {
push @name, ucfirst(random_dictionary_word);
$words--;
}
if ($suffix) {
push @name, ucfirst(random_company_suffix)
}
return join(' ', @name);
}
warn random_client_name, "\n";
@mattfoster
Copy link
Author

Some examples of output:

  • Unenkindled Parage LLP
  • Combo Oxboy Incorporated
  • Notionalist Watson-Watt B.V.
  • Gray Unerroneousness PLC
  • Methanol Nutrias LLC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment