Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- if ($#ARGV != 1)
- {
- print "usage ./lab3 forward reverse";
- }
- open($file1, $ARGV[0]) or die "cannot open file";
- open($file2, $ARGV[1]) or die "cannot open file";
- $counter = 0;
- $counter2 = 0;
- print "\n";
- print "Forward Zone File:\n";
- while ($line = <$file1>)
- {
- if ($line =~ /in\s+a/ig)
- {
- @array = split(" ", $line);
- $hostnamecontents[$counter] = $array;
- $hostnamecontents[$counter] = $array[0];
- print $hostnamecontents[$counter];
- print "\n";
- @ipadd = split('\.', $array[3]);
- $ipfor[$counter2] = $ipadd;
- $ipcontents[$counter] = $ipadd[3];
- print $ipcontents[$counter];
- print "\n";
- $counter++;
- }
- }
- print "\n";
- print "Reverse Zone File:\n";
- while($line2 = <$file2>)
- {
- if ($line2 =~ /in\s+ptr/ig)
- {
- @array2 = split(" ", $line2);
- @rhostname2 = split('\.', $array2[3]);
- $rhostfor[$counter2] = $rhostname2;
- $rhostnamecontents[$counter2] = $rhostname2[0];
- $rip2[$counter2] = $array2[0];
- print "$rhostnamecontents[$counter2]\n";
- print "$rip2[$counter2]";
- print "\n";
- $counter2++;
- }
- }
- print "\n";
- for ($i=0, $i<$counter2, $i++)
- {
- $ipcombined = join(".", $ipadd[$i]);
- print "ip is: $ipcombined\n";
- }
- close ($file1, $file2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement