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 402B

12345678910111213141516171819202122232425
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use Text::GenderFromName;
  5. use 5.10.0;
  6. my ($male, $female, $unknown) = (0, 0, 0);
  7. while (my $name = <STDIN>) {
  8. chomp $name;
  9. my $gender = gender($name);
  10. if (! defined $gender) {
  11. $unknown++;
  12. next;
  13. }
  14. if ($gender eq 'm') {
  15. $male++;
  16. } elsif ($gender eq 'f') {
  17. $female++;
  18. }
  19. }
  20. say "male: $male, female: $female, unknown: $unknown";