For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > June 2005 > XML::Twig -- help with something small









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author XML::Twig -- help with something small
rishid@gmail.com

2005-06-07, 4:01 pm

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;
}

John Bokma

2005-06-07, 4:01 pm

rishid@gmail.com wrote:

> 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.

--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com