Perl 6
Using Perl 5 Embedding: Revision 5

Currently, Perl 5 embedding is enabled by default in Pugs. This allows to you use some Perl 5 modules from Perl 6. Here's a basic example:

 use perl5:CGI;
 my $q = CGI.new('a=Hello');
 say $q.param('a');

Notice that add the prefix perl5 when "using" the module, but otherwise use normal Perl 6 object notation. In that example were just passing the string 'a=Hello' to Perl 5. Sometimes additional effort is needed to successfully pass a more complex data structure from Perl 6 to Perl 5.

However, if you want to pass anything more than strings between Perl 6 and Perl 5, you may soon run into trouble. For example, Perl 6 does not allow named arguments to start with a dash but Perl 5 does. The general tool here will be to find a way to to apply eval('some code',:lang<perl5>), so that it returns some Perl 5 code at the appropriate spot.

Here's an example of using it to pass a named argument starting with a dash:

 use perl5:CGI;
 my $cookie = eval(q"
     my $q = CGI->new;
     $q->cookie( -name => 'Hello', value => 'World')
 ",:lang<perl5>);
 print $cookie;

Likewise, using "{}" for a hash reference may also need some help:

 use perl5:CGI;
 my $q = CGI.new( eval('{ a => "Hello" }',:lang<perl5>)  );
 say $q.param('a');

Importing from Perl 5

Currently explict imports work, but implicit ones to not. This works:

use perl5:Time::gmtime <gmtime>;
say gmtime.mday;

Examples


Upload Files

Click "Browse" to find the file you want to upload. When you click "Upload file" your file will be uploaded and added to the list of attachments for this page.

Maximum file size: 50MB

 
 
 
File Name Author Date Uploaded Size

Save Page As

Enter a meaningful and distinctive title for your page.

Page Title:

Tip: You'll be able to find this page later by using the title you choose.

Page Already Exists

There is already a page named XXX. Would you like to:

Save with a different name:

Save the page with the name "XXX"

Append your text to the bottom of the existing page named: "XXX"

Upload Files

Click "Browse" to find the file you want to upload. When you click "Add file" this file will be added to the list of attachments for this page, and uploaded when you save the page.

 
 
 
Add Tags

Enter a tag and click "Add tag". The tag will be saved when you save the page.

Tag: 

Suggestions: