use strict; use warnings; use IO::File; use DNS::ZoneParse; my @zonefiles = ; foreach my $zonefile (@zonefiles) { my $z = DNS::ZoneParse->new($zonefile); # change ttl in all MX records, for example my $mx = $z->mx; $_->{ttl} = 'foo bar' for (@$mx); # update ttl $z->new_serial(); # write the new zone file to disk my $zf = new IO::File "$zonefile", "w" or die "Error writing zonefile: $!"; print $zf $z->output(); }