#!/usr/bin/perl

$prefix = $ARGV[0] || 'D:\\ArabicPDT\\';

while (<STDIN>) {

    next unless $_ =~ /^[-+?!][-+?!] /;

    ($type, $address) = split /\t/, $_;

    push @{$data{$type}}, $address;
}

$\ = "\n";

print 'TrEd Filelist';

foreach $type (sort keys %data) {

    print '# ' . $type;
    
    foreach $address (@{$data{$type}}) {

	($coord, $source, $level) = $address =~ m%(?<![^/])(([^/]{3})[^/]*\.(morpho|syntax)\.[^/]*fs\#\#[0-9.-]+)$%;

	print $prefix . $source . '\\' . $level . '\\' . $coord;
    }
}
