I am wrong. As I just looked at the source code I saw that there is
already a method (_md5_hex) that can be used to get the checksum as
string.

#!/usr/bin/perl6

Q:PIR {
    load_bytecode 'Digest/MD5.pbc'
    .local pmc md5sum, md5_sum_get
    md5sum = get_root_global ['parrot'; 'Digest'], '_md5sum'
    $P0 = md5sum('foo')
    md5_sum_get = get_root_global ['parrot'; 'Digest'], '_md5_hex'
    $S0 = md5_sum_get($P0)
    say $S0
}

-- Gerd


Am Donnerstag, den 10.06.2010, 08:48 +0200 schrieb Gerd Pokorra:
> I think the easiest way would be to add a method in the file
> "runtime/parrot/library/Digest/MD5.pir" that gives the md5 checksum back
> as a string. I can look at the source code and try to do this for you if
> you want and add a method may be called "_md5_sum_get".
> 
> -- Gerd
>  
> Am Mittwoch, den 09.06.2010, 16:24 +0200 schrieb Cosimo Streppone:
> > On Wed, 09 Jun 2010 16:00:42 +0200, Gerd Pokorra <g...@zimt.uni-siegen.de>  
> > wrote:
> > 
> > > Here is a simple example that works.
> > >
> > > #!/usr/bin/perl6
> > >
> > > Q:PIR {
> > >     load_bytecode 'Digest/MD5.pbc'
> > >     .local pmc md5sum, md5print
> > >     md5sum = get_root_global ['parrot'; 'Digest'], '_md5sum'
> > >     $P0 = md5sum('foo')
> > >     md5print = get_root_global ['parrot'; 'Digest'], '_md5_print'
> > >     md5print($P0)
> > > }
> > 
> > Cool! Works for me too!
> > And also inside a subroutine.
> > However, how do I return the md5sum back to perl6?
> > 
> > I blindly tried:
> > 
> >    sub mysub (Str $text) {
> >      my $md5_sum = Q:PIR {
> >          load_bytecode 'Digest/MD5.pbc'
> >          .local pmc md5sum, md5print
> >          md5sum = get_root_global ['parrot'; 'Digest'], '_md5sum'
> >          $P0 = find_lex '$text'
> >          %r = md5sum($P0)
> >      };
> >      return $md5_sum;
> >    }
> > 
> >    say mysub('foo');
> > 
> > It doesn't panic, but it doesn't print anything either.
> > 
> 


Reply via email to