#! /usr/bin/perl

if ( open(AUTOMASTER, '/etc/auto.master') ) {
    my @autos = grep !/^\s*#/ && /\S/, <AUTOMASTER>;
    close AUTOMASTER;

    foreach (@autos) {
        my ($mountpoint, $map) = split /\s+/;
        #print "$mountpoint -> $map\n";
        print "On $mountpoint : ";
        if ( open(A, $map) ) {
            if (-x $map) {
                print "(executable map!)";
            }
            my @lines = grep !/^\s*#/ && /\S/, <A>;
            close A;
            print "\n  ", join("  ", @lines), "\n";
        }
        else {
            print "Error: could not open $map ($!)\n";
        }
        
        #print "$mountpoint -> $map\n";
        #print @autos;
    }
}

open(FSTAB, '/etc/fstab') or die "Cannot open /etc/fstab ($!)\n";
my @fstabs = grep !/^\s*#/ && !/^proc/ && /\S/, <FSTAB>;
close FSTAB;
print "In /etc/fstab:",
    join("  ", @fstabs),
    "\n";
