XML::Twig -- help with something small

R

rishid

Hi,

I need to create about 100 twigs or so in my program I am writing and
wanted to create a quick method to just create twigs with one line. I
created this subfunction. So I can just call this function with a
single. The problem I am having is the function call ($temp[1]), Perl
thinks it is a bareword/string and not a function. Anyway to "cast" it
to a sub routine?

Thanks,
Rishi Dhupar

use strict;
use XML::Twig;
quickTwig("DBMS", "getXMLDBInfo", "tmp/$inputHash{'host'}/DBList.xml");
sub quickTwig {
# @temp = [Node, Function, File]
my @temp = @_;
my $twig = XML::Twig->new(twig_handlers => { $temp[0] => $temp[1] });
$twig->parsefile($temp[2]);
$twig->purge;
}
 
J

John Bokma

Hi,

I need to create about 100 twigs or so in my program I am writing and
wanted to create a quick method to just create twigs with one line. I
created this subfunction. So I can just call this function with a
single. The problem I am having is the function call ($temp[1]), Perl
thinks it is a bareword/string and not a function. Anyway to "cast"
it to a sub routine?

Thanks,
Rishi Dhupar

use strict;
use XML::Twig;
quickTwig("DBMS", "getXMLDBInfo",
^^^^^^^^^^^^

that's not a function, that's a string,
you probably want to pass a reference to a sub
"tmp/$inputHash{'host'}/DBList.xml"); sub quickTwig {
# @temp = [Node, Function, File]

extremely misleading comment
my @temp = @_;

my ( $node, $function, $file ) = @_;

etc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top