I am trying to find out how to use (in perl6) perl5 modules that contain
subroutines.
Here are two scripts from standard modules. Both work in perl5, but I
cant find a way to use them using pugs (I am using the Debian package
with version 6.2.10-4build1 on GNU/Linux/Ubuntu)
<start of perl5 script - straight out of the Time::gmtime documentation>
use strict;
use Time::gmtime;
my $gm = gmtime();
printf "The day in Greenwich is %s\n",
(qw(Sun Mon Tue Wed Thu Fri Sat Sun))[ $gm->wday() ];
<end of script>
<terminal output, under linux>
$ perl ./p5test.pl
Tue
<start of perl6 script>
use perl5:Time::gmtime;
my $gm = gmtime();
printf "The day in Greenwich is %s\n",
(qw(Sun Mon Tue Wed Thu Fri Sat Sun))[ $gm.wday() ];
# note the change from -> to .
<end of script>
<terminal output>
$ pugs ./p5test.p6
*** No compatible subroutine found: "&gmtime"
at ./p5test.p6 line 6, column 10-18
<second example>
<perl5 script>
use strict;
use Text::Balanced qw(extract_tagged);
my $txt = '<atag>now and then</atag>some text';
my @ret_pars = extract_tagged($txt);
print join("\n",@ret_pars),"\n";
print "[EMAIL PROTECTED]" if $@;
<end script>
<terminal output>
$ perl ./p5test.pl
<atag>now and then</atag>
some text
<atag>
now and then
</atag>
<perl6 script>
use perl5:Text::Balanced qw(extract_tagged);
my $txt = '<atag>now and then</atag>some text';
my @ret_pars = extract_tagged($txt); # this is line 8
print join("\n",@ret_pars),"\n";
#print "[EMAIL PROTECTED]" if $@;
# commented this out as caused a compile error, probably another
# variable should be used for errors.
<terminal output>
$ pugs ./p5test.p6
*** No compatible subroutine found: "&extract_tagged"
at ./p5test.p6 line 5, column 16-36
<terminal output end>
What is going wrong? What have I done wrong? I tried several
alternatives, like putting the & sigil on the function. I just got
different sorts of errors.
Richard