On Thursday 01 March 2007 06:52, Randall wrote:
> I've translated the following PHP snippet:
>
> $data = array();
> $num = 0;
>
> $data[$num]['title'] = 'Name';
> $data[$num]['data'] = 'Randall';
> $num++;
>
> As this Perl:
>
> my @data;
> my $num = 0;
>
> $data[$num]['title'] = 'Name';
> $data[$num]['data'] = 'Randall';
> $num++;
>
[..]
> Only a tiny part of @data can be read back in PHP. It seems the two
> structures aren't equal after all.
>
> I've tried also something along these lines:
>
> my %h = ( title => '', data => '');
> my @data = ( \%h );
> my $num = 0;
>
> $data[$num]{'title'} = 'Name';
> $data[$num]{'data'} = 'Randall';
> $num++;
>
>
> This goes a bit further (slightly more data is available for
> deserialization) but it doesn't work either.
>
> What am I doing wrong?
>
>
Hi Randall,
I don't actually *know* if this helps you, but since PHP does have the concept
of associative arrays, I could imagine
that you'll need to write both PHP arrays as hashes in Perl - something like:
my %data = { 0 => { title => 'Name', data => 'Randall' },
1 => { title => 'email', data => '[EMAIL PROTECTED]' }
};
HTH,
Philipp
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/