Skip to content

Instantly share code, notes, and snippets.

@bradfitz
Created April 16, 2012 04:56
Show Gist options
  • Save bradfitz/2396390 to your computer and use it in GitHub Desktop.
Save bradfitz/2396390 to your computer and use it in GitHub Desktop.
Cognac Hacking
#!/usr/bin/perl
use strict;
my $rockettop = <<'END';
.
/ \
/ \
END
my $rocketmid = <<'END';
| X |
| |
END
my $rocketbot = <<'END';
/ | | | \
END
my @girls;
for my $line (split(/\n/, `curl -s http://www.census.gov/genealogy/names/dist.female.first`)) {
$line =~ s/\s.+//;
push @girls, $line;
}
while (1) {
my $girl = $girls[int(rand() * scalar(@girls))];
my $rocket = $rockettop;
for my $let (split(m//, $girl)) {
my $frag = $rocketmid;
$frag =~ s/X/$let/;
$rocket .= $frag;
}
$rocket .= $rocketbot;
my $indent = " " x int(rand() *30.0);
my @lines = split(/\n/, $rocket);
for my $l (@lines) {
print "$indent$l\n";
select undef, undef, undef, 0.05;
}
print "\n";
}
@dickhardt
Copy link

Nice to see you are still hacking in Perl. I've moved onto nodejs. :)

@bradfitz
Copy link
Author

Barely. I write almost exclusively in Go these days. (that's my full-time job at Google, working on Go).

This was the first Perl I'd written in years.

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