in reply to identifying dns zone filename

Use the on_error parameter:
foreach $filename (@files) { $rr = Net::DNS::ZoneFile::Fast::parse( file=>$filename, on_error => sub {print "Error in $filename\n";} ); }

Replies are listed 'Best First'.
Re^2: identifying dns zone filename
by papai (Novice) on Oct 23, 2009 at 12:20 UTC

    Yes that will print the filename, however now I do not get the line number? I need both. I also tried

    foreach $filename (@files) { $rr = Net::DNS::ZoneFile::Fast::parse( file=>$filename, on_error => sub {print "Error in $filename on line: $ln\n";} ); }

    but that didn't work

      According to Net::DNS::ZoneFile::Fast:

      on_error
      An optional parameter, user-defined error handler. If specified, it must be a subroutine reference, which will be called on any error. This subroutine will be passed two parameters: a line number in the zone, where the error occurred, and the error description.
      So:
      foreach $filename (@files) { $rr = Net::DNS::ZoneFile::Fast::parse( file=>$filename, on_error => sub { my ($ln,$desc) = @_; print "Error in $filename on line: $ln\n"; print "Description: $desc\n\n"; } ); }
         Thanks, works like a charm....