Skip to content

Instantly share code, notes, and snippets.

@Gnarfoz
Created February 14, 2019 10:33
Show Gist options
  • Save Gnarfoz/e721c49df7e3113fa8dea38ced97d7fb to your computer and use it in GitHub Desktop.
Save Gnarfoz/e721c49df7e3113fa8dea38ced97d7fb to your computer and use it in GitHub Desktop.
WoW combatlog splitter
#!/usr/bin/perl
use strict;
use warnings;
$| = 1;
my ($infilename, $in, $out) = ("WoWCombatLog.txt");
my ($year, $month, $day) = (2012);
my ($lastday, $i) = (0, 0);
print "A simple World of Warcraft combat log splitter\n==============================================\n\n";
print "Splitting up $infilename.\n";
open $in, "<", $infilename or die "Couldn't open $infilename: $!\n";
while (<$in>) {
($month, $day) = (/^(\d{1,2})\/(\d{1,2})/);
if ($lastday != $day) {
$month = sprintf("%02d",$month);
$day = sprintf("%02d",$day);
$lastday = $day;
print "\n*** New day! ***\n";
my $outfilename = "WoWCombatLog_$year-$month-$day.txt";
open $out, ">", $outfilename or die "Couldn't open output file $outfilename for writing: $!\n";
print "Writing to $outfilename";
}
print $out $_; $i++;
print "." if $i % 10000 == 0;
}
close $in or die "$in: $!";
close $out or die "$in: $!";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment