http://www.perlmonks.org?node_id=368391

Tanalis has asked for the wisdom of the Perl Monks concerning the following question:

Monks,

I am currently working on a web-based portal-style application that must be capable of importing a number of services (modules) at run-time.

Each service provides different functionality, for example a hook into an existing system to allow data to be aggregated, or providing some completely new functionality.

The portal system under construction makes use of a fixed interface, implemented and extended by each service to allow the portal to dynamically determine each service's interface at run-time. For example, Service X might implement methods get_legacy_data and update_legacy_data, returning a description of these methods via a call to the required get_service_interface method.

For the majority of method calls, a simple list of parameters is passed, using the following code:

sub call_service { my $svc = shift; my $cmd = shift; my @args = @_; foreach ( @args ) { $_ = "\"$_\"" } my $arg = join ",", @args; return eval $svc . "::" . $cmd . "(" . $arg . ")"; }

My problem comes where I need to pass a data structure, rather than a flat list of elements, into some service, for example an array of arrays. The method above simply converts each array in the structure into a string, which obviously isn't the intended result.

Can anyone suggest a way of changing the sub above to allow more complex data structures to be passed?

Thanks in advance,