Hello Derek
Am Mittwoch, 2. M�rz 2005 17.19 schrieb [EMAIL PROTECTED]:
> [...]
> > btw: If the 1st FOR LOOP loop failed, @a is empty, so maybe you should
> > move the last 3 lines in the 1st FOR LOOP if branch.
>
> tkx for the pointer! So here is what you mean?
>
>
> foreach ($query->answer) {
> if ( $_->type eq 'NS' ) {
> #next unless $_->type eq "A";
> foreach ($_->nsdname) {
> push (@a,$_) if $_ =~ "svr";
> $e++;
> } # END 2nd FOR LOOP
> } else {
> print F "DNS query failed: ", $res->errorstring, "\n";
> } # END 2nd IF
>
> @a = sort { $a cmp $b } @a;
> print F $a[0],"\n";
> print F $a[1],"\n";
> } # END 1st FOR LOOP
>
> } # END 1st IF
No, I meant something like the following to catch the case where @a is not
filled with any values:
> if ( $query != 0 or $query != undef or $query != ' ' ) {
> foreach ($query->answer) {
> if ( $_->type eq 'NS' ) {
> #next unless $_->type eq "A";
> foreach ($_->nsdname) {
> push (@a,$_) if $_ =~ "svr"; # fill @a
> $e++;
> } # END 2nd FOR LOOP
> } else {
> print F "DNS query failed: ", $res->errorstring, \n";
> } # END 2nd IF
> } # END 1st FOR LOOP
+ if (@a) {
+ @a = sort { $a cmp $b } @a;
+ print F $a[0],"\n", $a[1],"\n";
+ }
> } # END 1st IF
- @a = sort { $a cmp $b } @a;
- print F $a[0],"\n";
- print F $a[1],"\n";
if the 1st IF branch is not visited, @a is always empty;
if it is visited, @a _may_ be filled with values
:-)
greetings joe
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>