Small script for old gaim logging

Christopher Nehren apeiron at
Thu Jan 15 23:11:49 PST 2004

Personally I don't like the new logging format that Gaim uses, so I
wrote this Perl script to move logs kept in the new format to the old
format. I know at least one other person who's interested in this, so I
figured that other people might be interested as well. It's mostly easy
to understand, and should work with anything that Gaim produces. If
anyone has any problems with it, the way it's written, or anything about
it, please do email me.

=== cut here ===
use strict;
use warnings;

use File::Basename;
use Tie::File;

# Change this to where your Gaim log files are. The default should work if you 
# haven't changed anything. The trailing / is important for now, at least until
# I teach this script how to handle not having one. This needs to be a full
# path -- no ~ or similar expansions. Of course, Perl hackers know that
# you can interpolate, so referring to one's own ~ doesn't need a ~.
my $gaim_log_path = "$ENV{'HOME'}/.gaim/logs/";

# Set this to 1 if you want to unlink (rm) the log files as they're processed.
# This script doesn't -- and won't ever -- have any way of telling whether it
# added some text to a log file. If it's set to 0, you'll have to remove the
# files yourself, or you'll get duplicates upon each subsequent run.
$unlink = 1;

chdir $gaim_log_path;
my @all_files = glob '**/**/**/**';
s#^/## for @all_files;
for my $fullpath (@all_files)
	my ($name, $path, undef) = fileparse($fullpath, '.txt');
	my ($protocol, $source, $destination) = split(/\//, $path);
	tie my @newlog, 'Tie::File', $fullpath 
		or die "Can't tie $fullpath to \@newlog: $!";
	chomp foreach @newlog;
	open OLDLOG, '>>', "${gaim_log_path}${destination}.log"
		or die "Can't open old log file $destination: $!";
	print OLDLOG "$_\n" foreach @newlog;
	close OLDLOG or die "Can't close old log file $destination: $!";
	untie @newlog;
	unlink $fullpath if $unlink;
=== cut here ===
I abhor a system designed for the "user", if that word is a coded
pejorative meaning "stupid and unsophisticated".  -- Ken Thompson
Please CC me in all replies, even if I'm on the relevant list(s).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url :

More information about the freebsd-ports mailing list