X-Git-Url: https://git.p6c8.net/selfforum.git/blobdiff_plain/5eee41e4c8f4a9f494d4457c088803a260efcac3..37166eaf544814bc3a164b0574fb16d0cb369ad6:/selfforum-cgi/shared/Posting/_lib.pm diff --git a/selfforum-cgi/shared/Posting/_lib.pm b/selfforum-cgi/shared/Posting/_lib.pm index 05a0285..5441830 100644 --- a/selfforum-cgi/shared/Posting/_lib.pm +++ b/selfforum-cgi/shared/Posting/_lib.pm @@ -13,9 +13,6 @@ package Posting::_lib; use strict; -use vars qw(@EXPORT_OK); -use base qw(Exporter); - use Encode::Plain; $Encode::Plain::utf8 = 1; use XML::DOM; @@ -24,10 +21,13 @@ use XML::DOM; # Export # ==================================================== -@EXPORT_OK = qw(get_message_header get_message_body get_message_node get_body_node parse_single_thread - hr_time short_hr_time long_hr_time - get_all_threads create_forum_xml_string - save_file); +use base qw(Exporter); +@Posting::_lib::EXPORT_OK = qw( + get_message_header get_message_body get_message_node get_body_node parse_single_thread parse_xml_file + hr_time short_hr_time long_hr_time + get_all_threads create_forum_xml_string + save_file +); # ==================================================== # Access via XML::DOM @@ -140,6 +140,26 @@ sub get_message_node ($$$) wantarray ? ($mnode, $tnode) : $mnode; } +### sub parse_xml_file ($) ##################################################### +# +# load the specified XML-File and create the DOM tree +# this sub is only to avoid errors and to centralize the parse process +# +# Params: $file filename +# Return: XML::DOM::Document Object (Document Node) or false +# +sub parse_xml_file ($) { + my $file = shift; + my $xml = eval { + local $SIG{__DIE__}; + new XML::DOM::Parser (KeepCDATA => 1) -> parsefile ($file); + }; + + return if ($@); + + $xml; +} + ########################### # sub parse_single_thread # @@ -572,4 +592,4 @@ sub long_hr_time ($) { # ==================================================== # making require happy -1; +1; \ No newline at end of file