|
Perl 6
Using Perl 5 Embedding: Revision 8
Perl 5 embedding is enabled by default in Pugs. This allows to you use some Perl 5 modules from Perl 6. Loading and importing from Perl 5use perl5:CGI; Currently explict imports work, but implicit ones to not. This works: use perl5:Time::gmtime <gmtime>; say gmtime.mday; Object-Oriented ClassesAfter loading a Perl5 OO clas, you can use Perl 6 OO notation to call methods on it. See CGI examples below. Examples of Passing Data to Perl 5Quick Reference
Strings
use perl5:CGI;
my $q = CGI.new('a=Hello');
say $q.param('a');
Hash references
use perl5:CGI;
my $q = CGI.new( { a => "Hello" } );
say $q.param('a');
This works too:
my %h = ( a => "Hello" );
use perl5:CGI;
my $q = CGI.new(\%h);
say $q.param('a');
Hashes and Named Argumentsyour_perl5_func(%perl6_hash.kv)
Note, Perl 6 does not allow named arguments to start with a dash but Perl 5 does. use perl5:CGI; my $q = CGI.new; my $cookie = $q.cookie( %( '-name' => 'Hello', value => 'World' ).kv ); print $cookie; Examples
|