#!/usr/bin/perl -w use strict; my $ifile = shift; open IFILE, '<', "$ifile" || die "Couldn't open file: $!"; open OFILE, '+>', 'new-data' || die "Couldn't open outfile: $!"; while (my $line = ) { # is the line an MX record? if ($line =~ /^@.*mail(\d+).*\z/xms) { # is it less than or equal to 8? if ($1 <= 8) { print OFILE $line; } } # print everything else to the new file else { print OFILE $line; } } close IFILE; close OFILE;