do { if ( $input_xml ) { $dom = XML::LibXML->load_xml( string => $input_xml ); my $isEmpty = !$dom->documentElement->hasChildNodes(); last if $isEmpty; say $fh $input_xml; $offset = $offset + $record_limit; say $offset; } } while ($input_xml = Get_CMDB_CI()); close($fh) || warn "close failed: $!";