<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">NAME

    Wasm - Write Perl extensions using Wasm

VERSION

    version 0.02

SYNOPSIS

    lib/MathStuff.pm:

     package MathStuff;
     
     use strict;
     use warnings;
     use base qw( Exporter );
     use Wasm
       -api =&gt; 0,
       -wat =&gt; q{
         (module
           (func (export "add") (param i32 i32) (result i32)
             local.get 0
             local.get 1
             i32.add)
           (func (export "subtract") (param i32 i32) (result i32)
             local.get 0
             local.get 1
             i32.sub)
           (memory (export "frooble") 2 3)
         )
       };
     
     our @EXPORT_OK = qw( add subtract );
     
     1;

    mathstuff.pl:

     use MathStuff qw( add subtract );
     
     print add(1,2), "\n";      # prints 3
     print subtract(3,2), "\n", # prints 1

DESCRIPTION

    WARNING: WebAssembly and Wasmtime are a moving target and the interface
    for these modules is under active development. Use with caution.

    The Wasm Perl dist provides tools for writing Perl bindings using
    WebAssembly (Wasm).

OPTIONS

 -api

     use Wasm -api =&gt; 0;

    As of this writing, since the API is subject to change, this must be
    provided and set to 0.

 -exporter

     use Wasm -api =&gt; 0, -exporter =&gt; 'all';
     use Wasm -api =&gt; 0, -exporter =&gt; 'ok';

    Configure the caller as an Exporter, with all the functions in the
    WebAssembly either @EXPORT (all) or @EXPORT_OK C(&lt;ok&gt;).

 -file

     use Wasm -api =&gt; 0, -file =&gt; $file;

    Path to a WebAssembly file in either WebAssembly Text (.wat) or
    WebAssembly binary (.wasm) format.

 -package

     use Wasm -api =&gt; 0, -package =&gt; $package;

    Install subroutines in to $package namespace instead of the calling
    namespace.

 -self

     use Wasm -api =&gt; 0, -self;

    Look for a WebAssembly Text (.wat) or WebAssembly binary (.wasm) file
    with the same base name as the Perl source this is called from.

    For example if you are calling this from lib/Foo/Bar.pm, it will look
    for lib/Foo/Bar.wat and lib/Foo/Bar.wasm. If both exist, then it will
    use the newer of the two.

 -wat

     use Wasm -api =&gt; 0, -wat =&gt; $wat;

    String containing WebAssembly Text (WAT). Helpful for inline
    WebAssembly inside your Perl source file.

SEE ALSO

    Wasm::Wasmtime

      Low level interface to wasmtime.

AUTHOR

    Graham Ollis &lt;plicease@cpan.org&gt;

COPYRIGHT AND LICENSE

    This software is copyright (c) 2020 by Graham Ollis.

    This is free software; you can redistribute it and/or modify it under
    the same terms as the Perl 5 programming language system itself.

</pre></body></html>