Skip to content

Instantly share code, notes, and snippets.

@evandhoffman
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evandhoffman/1f25ad3034f165faea4a to your computer and use it in GitHub Desktop.
Save evandhoffman/1f25ad3034f165faea4a to your computer and use it in GitHub Desktop.
Perl script to parse my old everquest logs.
#!/usr/local/bin/perl
use strict;
my $date_regex = qr/^\[(\w{3}) (\w{3}) (\d{2}) (\d{2}):(\d{2}):(\d{2}) (\d{4})\]/;
my $guild_msg = qr/(\w+) tells the guild, '([^']+)'/;
my $channel_msg = qr/(\w+) tell(?:s?) ([\w]+):(?:\d+), '([^']+)'/;
my $raid_msg = qr/(\w+) tells the raid, '([^']+)'/;
my $damage = qr/([\w\s]+) hits ([\w\s]+) for (\d+) points of damage./;
my $spell = qr/([\w\s]+) begins to cast a spell. (?:<([\w\s]+)>)/;
my $loc1 = qr/There are (\d+) player(?:s?) in ([\w\d,]+)./;
my $tell = qr/(\w+) (?:tells|told) (\w+), '([^']+)'/;
while(<>) {
if (my ($dw, $mon, $day, $hr, $min, $sec, $year) = ($_ =~ $date_regex)) {
# print "year: $year\n";
}
if (my ($handle, $message) = ($_ =~ $guild_msg)) {
print "GUILD\t$handle\t$message\n";
}
if (my ($handle, $channel, $message) = ($_ =~ $channel_msg)) {
print "$channel\t$handle\t$message\n";
}
if (my ($handle, $message) = ($_ =~ $raid_msg)) {
print "RAID\t$handle\t$message\n";
}
if (my ($attacker, $victim, $damage) = ($_ =~ $damage)) {
print "DAMAGE\t$attacker=>$damage=>$victim\n";
}
if (my ($caster, $spell) = ($_ =~ $spell)) {
print "SPELL\t$caster ($spell)\n";
}
if (my ($count, $zone) = ($_ =~ $loc1)) {
print "LOC\t$zone\n";
}
if (my ($speaker, $listener, $message) = ($_ =~$tell)) {
print "TELL\t$speaker\t$listener\t$message\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment