https://github.com/freysie/perl-core
Evaluate Perl code from within apps on Apple platforms.
https://github.com/freysie/perl-core
interoperability perl swift
Last synced: 2 months ago
JSON representation
Evaluate Perl code from within apps on Apple platforms.
- Host: GitHub
- URL: https://github.com/freysie/perl-core
- Owner: freysie
- License: mit
- Created: 2022-01-23T00:59:45.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-03-09T21:38:26.000Z (over 2 years ago)
- Last Synced: 2025-10-22T07:38:57.658Z (8 months ago)
- Topics: interoperability, perl, swift
- Language: C
- Homepage: https://freyaalminde.github.io/documentation/perlcore
- Size: 12.7 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PerlCore
Evaluate Perl code from within an app, and support Perl scripting of your app.
## Installation
```swift
.package(url: "https://github.com/freysie/perl-core.git", from: "0.1.0")
```
```swift
import PerlCore
```
## Documentation
Online documentation is available at [freysie.github.io/documentation/perlcore](https://freysie.github.io/documentation/perlcore/).
## Overview
The PerlCore framework provides the ability to evaluate Perl code from within Swift-based apps. You can also use PerlCore to insert custom objects into the Perl environment.
```swift
let interpreter = PerlInterpreter.shared
interpreter["prefix"]!.asString = "Just "
let script = "$prefix . reverse q(rekcaH lreP rehtonA)"
let result = interpreter.evaluateScript(script)
assert(result.asString == "Just Another Perl Hacker")
```
PerlCore 0.1.0 includes Perl 5.30.3.
## Roadmap
The ability to create multiple interpreters may be added, and `PerlInterpreter.shared` removed. (This requires building Perl with `-Dusemultiplicity`.)
To better support the App Store guidelines, all modules should ideally be embedded in the binary. In this case, to avoid bloat, a script for customizing the Perl distribution may be added.
A complete build script for building `libperl.xcframework` for every platform is currently under development.
## Acknowledgements
Based on [Dan Kogai’s blog post about Perl in Swift](https://qiita.com/dankogai/items/d63dfda25088165deed5).
Uses [`perl-cross` by Alex Suykov](https://github.com/arsv/perl-cross) for cross-compiling Perl.