What happened to this expression evalin Perl? I am trying to verify that XML is valid by catching any exceptions obtained from parsing a file using XML :: LibXML :
eval
use XML::LibXML; my $parser = XML::LibXML->new(); #creates a new libXML object. eval { my $tree = $parser->parse_file($file) # parses the file contents into the new libXML object. }; warn() if $@;
Easy, $ tree is not saved after eval {}. Brackets in perl, as a rule, always provide a new area. And the warning requires that you provide your arguments to $ @.
eval {}
my $tree; eval { # parses the file contents into the new libXML object. $tree = $parser->parse_file($file) }; warn $@ if $@;
You declare $ tree inside curly braces, which means that it does not exist behind the closing bracket. Try the following:
use XML::LibXML; my $parser = XML::LibXML->new(); my $tree; eval { $tree = $parser->parse_file($file) # parses the file contents into the new libXML object. }; warn("Error encountered: $@") if $@;
Source: https://habr.com/ru/post/1728134/More articles:WPF Documentviewerbase.Print. Удалить диалоговое окно - wpfhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1728130/how-to-use-repo-as-repository-on-hudson&usg=ALkJrhj9EyZor7TVV3rL1lmGxdW4uoNG-gdo things with smarty function return value? - javascriptinsert new element into array inside hash - ruby-on-railshttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1728133/how-to-handle-authenticated-user-access-to-resources-in-document-oriented-system&usg=ALkJrhguYJrla6oVbK_RkQYpkuODQPVAcADoes Android launch OpenGL ES 1.1 or 1.0? - androidWhy specify an explicit database connection? - phpHow to use an entity structure at the business level and / or data level? - c #Почему этап undefined в моем классе ActionScript 3, хотя я импортировал класс Stage? - actionscript-3Silverlight: passing a complex object between pages - c #All Articles