|
From: Chip K. <Chi...@op...> - 2001-12-15 20:20:29
|
The "Webmin Modules" documentation & example code indicate that there is no
restriction on return value types from remote_foreign_call() but I am
getting some odd behaviour when calling a remote function which returns an
array as opposed to an array reference. The following code fragments
illustrate what I am seeing:
---------------------------------------------------
# The following two functions are in a module on host #1 :
sub remote_function1()
{
# create an empty array.
@empty_array1 = ();
# return the empty array.
return(@empty_array1);
}
sub remote_function2()
{
# create an empty array.
@empty_array2 = ();
# return a REFERENCE to the empty array.
return(\@empty_array2);}
}
-------------------------------------------------
# The following function is in a module on host #2 and calls the
# two remote functions on host #1:
sub sandbox()
{
@array1 = &remote_foreign_call(some_server, some_module, remote_function1);
$length_array1 = scalar(@array1);
$ref_array2 = &remote_foreign_call(some_server, some_module,
remote_function2);
@array2 = @$ref_array2;
$length_array2 = scalar(@array2);
}
-------------------------------------------------
Executing the function "sanbox()" above will result in $length_array1 == 1
(WRONG), while $length_array2 == 0 (CORRECT). Why the descrepency? Should
functions called via remote_foreign_call() always return references? I am
new to Perl, but the serialize/unserialize_variable() functions in
web-lib.pl suggest that only references to arrays & hashes are supported.
thx,
Chip Kaye
|