#!/usr/bin/perl -w use strict; # This script allows the meta spread across many archives to be gathered into a # single report. This report could then be manipulated in various ways as the # following example demonstrates: # $ todo.sh -s example.mar # $ report.pl | awk -F':' '$2 ~ /Low/ { print $1; }' my $mar = '../mar'; sub parse { my $path = shift; my @values; push @values, $path; foreach $_ (sort `$mar -t $path`) { chomp; my ($key, $value) = split(/=/); push @values, $value; } my $line = join(':', @values); return $line; } sub search { my $dir; $dir = '.' if !($dir = shift); opendir(DIR, $dir) || die "Failed to open directory $dir: $!"; my @files = grep { !/^\.$/ && !/^\.\.$/ } readdir(DIR); closedir DIR; foreach my $file (@files) { my $path = "$dir/$file"; if (-d $path) { search($path); } elsif ($path =~ /.*\.(mar)$/) { my $line = parse($path); print "$line\n"; } } } search(shift);