Mark Stosberg wrote: > > When Perl 5 has references and Perl 6 doesn't, I don't know what to > expect to when I need to pass a hash reference to a Perl 5 routine. > > Such details make no appearance currently in the Perl 6 spec, but I'm > trying to gather them on the wiki if you have anything to add: > > http://rakudo.org/perl6/index.cgi?using_perl_5_embedding
I saw there have been some commits lately to Perl5 embedding, so I tried some experiments with pugs to figure out if I could determine reliable ways pass hashes and arrays to Perl5, so that they are received as hashes, hashrefs, arrays, or arrayrefs, as appropriate. I came up with the following test. As you can see, with arrays I was able to pass them as a reference or not. However, when attempting to pass a hash, it always came through as a hash, never flattened. Have I missed something? my $p5_dumper = eval('sub {use Data::Dumper; print Dumper(@_); }', :lang<perl5>); my @a = <b c d>; $p5_dumper.(@a); # received as array $p5_dumper.([EMAIL PROTECTED]); # received as arrayref $p5_dumper.(VAR @a); # received as arrayref my %h = ( a => 1 ); $p5_dumper.(@%h); # received as hashref $p5_dumper.([,] %h); # received as hashref $p5_dumper.(|%h); # received as hashref $p5_dumper.(%h); # received as hashref $p5_dumper.(\%h); # received as hashref $p5_dumper.(VAR %h); # received as hashref