#!/usr/bin/perl
#
# Author: Peter Keel <killer@discordia.ch>
# This converts lha-files to tar'ed bzip2'ed-files.

die "Usage: $0 lhafile\n" unless($ARGV[0]);

chop ( $PWD = `pwd`);
$base_dir = $PWD;

foreach $file_name (@ARGV)
    {
	print STDERR "Processing '$file_name'\n";
	$new_file = $file_name;
        mkdir "/tmp/$file_name",755;
        system ("lha -xqw=/tmp/$file_name $file_name");
	$new_file =~ s/lha\b/tar.bz2/i;
        chdir ("/tmp/$file_name");
        system ("tar -cIf $new_file *");
        chdir $base_dir;
        system ("cp /tmp/$file_name/$new_file $base_dir");
        system ("rm -rf /tmp/$file_name");
    }

