[ale] Issue with sub name and XML::Parser

Christopher Fowler cfowler at outpostsentinel.com
Wed Dec 1 09:16:33 EST 2004


I'm trying to extract a parameter value from my tomcat web.xml.  I'm
using the subs version of XML Parser and am having a problem with an
xml tag name conflicting with syntax for a function name.

Here is the code:

#!/opt/SAM/perl/bin/perl -I/opt/SAM/perl-lib
                                                                                                                             use XML::Parser;
 
{
  package web_xml;
                                                                                                                             
  sub param-name {
  }
                                                                                                                             
  sub _param-name {
  }

  sub char_handler {
  }

}
 
sub get_data {
  my $data = "";
  open(F, "</usr/local/tomcat/webapps/AlarmCenter/WEB-INF/web.xml");
  while(<F>) {
    $data .= $_;
  }
  close(F);
  return $data;
}
 
sub main {
  my $data = get_data();
  my $parser = new XML::Parser(Style => 'Subs', Pkg => 'web_xml');
  $parser->setHandlers(Char  => \&web_xml::char_handler);
  $parser->parse($data);

  return;
}
main;
# vi: set ts=2 sw=2: #

web.xml:
<param-name>console-log-path</param-name><param-value>/u01/cms/logs/</param-value>


Perl does not like 'sub param-name'





More information about the Ale mailing list