Structs

The following structs are available globally.

  • A Perl interpreter.

    This type hides a pointer to the underlying C Perl interpreter and provides a clean Swifty interface to it. It doesn’t provide any guarantees about a Perl interpreter instance aliveness and should be used only while they are provided by outer conditions. Generally it is not a problem because a Perl interpreter is only created once on startup and destroyed on shutdown of a process. In the case of an XS module an interpreter aliveness is guaranteed during the scope of an XSUB call.

    Embedding a Perl interpreter

    let perl = PerlInterpreter.new()
    try perl.eval("print qq/OK\\n/") // Do something interesting with Perl
    perl.destroy()
    

    Writting an XS module

    @_cdecl("boot_Your__Module__Name")
    public func boot(_ perl: PerlInterpreter.Pointer) {
        let perl = PerlInterpreter(perl)
        // Create XSUBs
        PerlSub(name: "test", perl: perl) { () -> Void in
            print("OK")
        }
    }
    
    See more

    Declaration

    Swift

    public struct PerlInterpreter