in reply to Module Data Dump.

I am creating a module, for my own use, that will take an object an create an XML document based on the data inside that object, whether the object be a SCALAR, ARRAY, HASH, or an object defined by a user.

Sounds like XML::Dumper.

I have it set up, so that it starts by taking an object, and then either asking if it has a certain function that returns allow of the methods that the person wants to store data returned from, or checking if the object is a hash, array, or scalar. I have not debugged it yet, and I want to know ahead of time will the code:

Not sure I understand the question. Are you asking how to find if object has some method? It is easy:

my $object = whatever; my $method = whatever; if($object->can($method)) { print "Has method $method\n"; } else { print "Has no method $method\n"; }

See perldoc UNIVERSAL.

--
Ilya Martynov (http://martynov.org/)

Replies are listed 'Best First'.
Re: Re: Module Data Dump.
by dakedesu (Scribe) on Mar 27, 2002 at 20:25 UTC

    Well, the thing I was asking was how would I call the method defined in the variable. I already have the code testing with UNIVERSAL::can. I think I have just about figured it out:

    my $data = &{$object->$method}; # do stuff with Data...

    I will check out those modules though, cause there are several high chances that they will do this better than me.

    Sorry about how short my last message was, I was running out of time on a public terminal.

    DakeDesu teh Confused Werewolf.
    In perl, only those who are bless'd are treated as objects
    (Webpages under construction)

        You mean that will actually work? Well, it certainly seems logical :)

        DakeDesu teh Confused Werewolf.
        In perl, only those who are bless'd are treated as objects
        (Webpages under construction)