Andy Greenwood wrote: > I'm writing a script for work that will dig for DNS records for a > given domain name and put the entries into an array. At the end of the > digging, it outputs the array elements to the screen, asks if > everything looks good, and if so, writes them out to the shell and > builds a zone file. However, I've come across a wierd problem > > when I dig for MX records, they may or may not be in my list of > subdomains to dig for, so I call getAforMX(<mx server>) which should > track down the actual A record and push that into my dns_commands > array. However, when it comes back, it fails to do the same for the > remaining MX records > > here's the script. > ------------<start>---------------- > #!/usr/bin/perl > > use warnings; > use strict; > > my $domain = shift || die "Usage: dns_replicate <domain.name> [name > server [name server [...]]]";
As well as Jay's and Tom's comments I should point out that you are using the logical or (||) operator incorrectly. || has higher precedence than the assignment operator (=) so that should be either: ( my $domain = shift ) || die "Usage: dns_replicate <domain.name> [name server [name server [...]]]"; or: my $domain = shift or die "Usage: dns_replicate <domain.name> [name server [name server [...]]]"; > my @servers = @ARGV || qw( ns1.myisp.net ns2.myisp.net ); This line has the problem that || doesn't work with lists so @ARGV is evaluated in scalar context, it is like saying: my @servers = scalar @ARGV || qw( ns1.myisp.net ns2.myisp.net ); so you need to do something like this: my @servers = @ARGV ? @ARGV : qw( ns1.myisp.net ns2.myisp.net ); John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short order. -- Larry Wall -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>