Something like this should do the job:
Code:
#!/usr/bin/perl
# 1. Open all zone files in /var/named
# 2. Add a line of text beneath all lines "mail IN" in each zone
use strict;
my $whatever = 'Text for line to add goes here';
opendir DIR, '/var/named';
my @d = readdir DIR;
foreach my $f (@d){
if (length $f > 2){
open IN, "</var/named/$f";
my @zone = <IN>;
close IN;
open OUT, ">/var/named/$f";
foreach my $line (@zone){
$line =~ s/\n//g;
print OUT $line . "\n";
if ($line =~ m/mail IN/){
print OUT $whatever . "\n";
}
}
close OUT;
print "$f updated\n";
}
}
Make sure you make a backup of your zone files first!