#!/usr/bin/perl -w use strict; my $ifile = shift; my $ofile = 'new_data'; open my $ifh, '<', $ifile or die "Couldn't open DNS file \"$ifile\": $!\n"; open my $ofh, '>', $ofile or die "Couldn't create output file \"$ofile\": $!\n"; while (my $line = <$ifh>) { # is the line an MX record? if ($line =~ /^@.*mail(\d+)/xms) { # is it less than or equal to 8? if ($1 <= 8) { print $ofh $line; } } # print everything else to the new file else { print $ofh $line; } } #### #!/usr/bin/perl -w use strict; # # Usage: # fixdns infile > outfile # # Usage for in place editing: # perl -i fixdns dnsfile # while (<>) { # is the line an MX record? if (/^@.*mail(\d+)/xms) { # is it less than or equal to 8? if ($1 <= 8) { print; } } # print everything else to the new file else { print; } }