Brand new to Perl (in training) and needs some help. Here is some code that I found that prints the results on the screen, fine, but I want it to be printed in a file. How can i do this? When I open the file and send it the output, I get garbage data.
Here is the code:
use Net::DNS;
my $res = Net::DNS::Resolver->new;
$res->nameservers("ns.example.com");
my @zone = $res->axfr("example.com");
foreach $rr (@zone) {
$rr->print;
}
When I add:
open(my $fh, '>', $filename) or die "Could not open file '$filename' $!";
.....
$rr -> $fh;
Daves source
share