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

Hi , i have a event which triggers for every 15min here i need to inovke a php file which contains array structure which i need to use in perl invoke function .
my $ua = LWP::UserAgent->new; $ua->timeout(120); $HA_HTTP_GET_URL .= htt://10.0.x.x/ui/sample.php; my $response = $ua->get($HA_HTTP_GET_URL); if ($response->is_success) { $HA_HTTP_GET_TRY_COUNT = 0; } else { $HA_HTTP_GET_TRY_COUNT++; }
Actually im expecting $response to conatin the array structure which is returned from sample.php file. Can u please suggest if there is any other way to get that array structure .

Replies are listed 'Best First'.
Re: Passing or returnin php array to Perl
by Anonyrnous Monk (Hermit) on Dec 20, 2010 at 13:13 UTC

    HTTP can only transfer serialized data structures (stream of bytes). So, without knowing how the PHP script is serializing the array (JSON, XML, home-grown, ...?), it's hard to tell how the Perl side should deserialize it...

Re: Passing or returnin php array to Perl
by samarzone (Pilgrim) on Dec 20, 2010 at 14:11 UTC

    Use json. sample.php page would return json encoded string and then you should decode $response for the data structure you require.

    JSON::XS is a good module to look at.

    -- Regards - Samar