#!/usr/bin/perl my $index; open REPO,"; close REPO; $c=~s%[\r\n]*%%g; open ROOT,"; close ROOT; $d=~s%[\r\n]*%%g; $d=~s%^.*:|/$%%; while (<>){ if ($index) { my $rcs = undef; if ($c =~ /\w/ && $_ =~ m|^RCS file: .*?/($c.*),v\r?$|) { $rcs=$1; } elsif ($_ =~ m|^RCS file: .*?$d/(.*),v\r?$|) { $rcs=$1; } if ($rcs) { my @rcspath=split m!/!,$rcs; my @indexpath=split m!/!,$index; my $path=join('/',@rcspath[0..@rcspath-@indexpath-1]); print $path||'.'; exit; } } else { if ($_ =~ m|^Index: (.*)\r?$|) { $index=$1; } } }