Dotfiles, utilities, and other apparatus.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

gender-from-name.pl 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/perl
  2. # This dates, as best I can now remember, to some argument about the
  3. # demographics of the SparkFun customer base, probably in the context of
  4. # whether we needed to Google Analytics everything to know things about our
  5. # customers. I think my point was approximately "friends, we already know that
  6. # most of our users are dudes and here is some rough confirmation of that
  7. # painfully obvious statement".
  8. #
  9. # Expects https://metacpan.org/pod/Text::GenderFromName
  10. #
  11. # No strong beliefs about the nature or appropriate quantization of sex,
  12. # gender, names, or human identity generally on the part of the author are
  13. # represented by this code fragment.
  14. use strict;
  15. use warnings;
  16. use Text::GenderFromName;
  17. use 5.10.0;
  18. my ($male, $female, $unknown) = (0, 0, 0);
  19. while (my $name = <STDIN>) {
  20. chomp $name;
  21. my $gender = gender($name);
  22. if (! defined $gender) {
  23. $unknown++;
  24. next;
  25. }
  26. if ($gender eq 'm') {
  27. $male++;
  28. } elsif ($gender eq 'f') {
  29. $female++;
  30. }
  31. }
  32. say "male: $male, female: $female, unknown: $unknown";