#!/usr/bin/perl

foreach my $f (@ARGV) {
	my %img;
	&read_file($f, \%img) || next;
	my $size = 0;
	foreach my $i (split(/\s+/, $img{'files'})) {
		my @st = stat($i);
		$size += $st[7];
		}
	print join("\t", $img{'id'}, $img{'manager'}, $img{'desc'}, $img{'version'}, $size),"\n";
	}

sub read_file
{
open(ARFILE, $_[0]) || return 0;
while(<ARFILE>) {
        s/\r|\n//g;
        if (!/^#/ && /^([^=]+)=(.*)$/) {
                $_[1]->{$_[3] ? lc($1) : $1} = $2;
                push(@{$_[2]}, $1) if ($_[2]);
                }
        }
close(ARFILE);
return 1;
}
