{"id":13810718,"url":"https://github.com/bazel-contrib/rules_perl","last_synced_at":"2026-03-07T15:01:31.124Z","repository":{"id":10613141,"uuid":"65765205","full_name":"bazel-contrib/rules_perl","owner":"bazel-contrib","description":"Perl rules for Bazel","archived":false,"fork":false,"pushed_at":"2026-03-05T14:31:20.000Z","size":175,"stargazers_count":31,"open_issues_count":13,"forks_count":46,"subscribers_count":6,"default_branch":"main","last_synced_at":"2026-03-05T16:59:50.692Z","etag":null,"topics":["bazel","bazel-rules","perl"],"latest_commit_sha":null,"homepage":null,"language":"Starlark","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bazel-contrib.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"open_collective":"bazel-rules-authors-sig"}},"created_at":"2016-08-15T21:09:34.000Z","updated_at":"2026-03-05T14:31:28.000Z","dependencies_parsed_at":"2023-12-16T02:44:48.077Z","dependency_job_id":"d6558450-a6f8-4e02-8a5e-fc02a76acc4f","html_url":"https://github.com/bazel-contrib/rules_perl","commit_stats":null,"previous_names":["bazel-contrib/rules_perl","bazelbuild/rules_perl"],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/bazel-contrib/rules_perl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bazel-contrib%2Frules_perl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bazel-contrib%2Frules_perl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bazel-contrib%2Frules_perl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bazel-contrib%2Frules_perl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bazel-contrib","download_url":"https://codeload.github.com/bazel-contrib/rules_perl/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bazel-contrib%2Frules_perl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30219250,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-07T14:02:48.375Z","status":"ssl_error","status_checked_at":"2026-03-07T14:02:43.192Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bazel","bazel-rules","perl"],"created_at":"2024-08-04T03:00:24.087Z","updated_at":"2026-03-07T15:01:31.105Z","avatar_url":"https://github.com/bazel-contrib.png","language":"Starlark","funding_links":["https://opencollective.com/bazel-rules-authors-sig"],"categories":["Additional language support"],"sub_categories":[],"readme":"[![Build status](https://badge.buildkite.com/2aaa805261d9267b26088e2763aa01f9ded00aaab18ed75c1e.svg)](https://buildkite.com/bazel/rules-perl-postsubmit)\n\n# Perl Rules\n\nThe Perl Toolchain utilizes the [relocatable perl](https://github.com/skaji/relocatable-perl) project.\n\n## Getting Started\n\nTo import rules_perl in your project, you first need to add it to your `WORKSPACE` file:\n\n\nIf you are still using `WORKSPACE` to manage your dependencies:\n\n```python\ngit_repository(\n    name = \"rules_perl\",\n    remote = \"https://github.com/bazelbuild/rules_perl.git\",\n    branch = \"main\",\n)\n\nload(\"@rules_perl//perl:deps.bzl\", \"perl_register_toolchains\", \"perl_rules_dependencies\")\n\nperl_rules_dependencies()\nperl_register_toolchains()\n```\n\nOnce you've imported the rule set into your `WORKSPACE`, you can then load the perl rules in your `BUILD` files with:\n\n```python\nload(\"@rules_perl//perl:perl.bzl\", \"perl_binary\")\n\nperl_binary(\n    name = \"hello_world\",\n    srcs = [\"hello_world.pl\"]\n)\n```\n\nPlease see `example` folder for more examples of how to include Perl scripts.\n\n## Mac Support\n\nCurrently, simple perl programs and Pure Perl modules work.\n\nModules that require compiling are not yet supported.\n\n## Windows Support\n\nThis repository provides a hermetic [Strawberry Perl](https://strawberryperl.com/) bazel toolchain for Windows. Usage of the toolchain in `perl_xs` rules is not yet supported.\n\n## Using Perl Modules\n\nPerl modules from [CPAN](https://www.cpan.org/) can be generated using the `cpan_compiler` rule in\nconjunction with the `cpan` module extension.\n\n### Current Steps\n\n1. Create a `cpanfile` per the [Carton](https://metacpan.org/pod/Carton) documentation.\n2. Create an empty `*.json` will need to be created for Bazel to use a lockfile (e.g. `cpanfile.snapshot.lock.json`)\n3. Define a `cpan_compiler` target:\n\n  ```python\n  load(\"//perl/cpan:cpan_compiler.bzl\", \"cpan_compiler\")\n\n  cpan_compiler(\n      name = \"compiler\",\n      cpanfile = \"cpanfile\",\n      lockfile = \"cpanfile.snapshot.lock.json\",\n      visibility = [\"//visibility:public\"],\n  )\n  ```\n\n4. `bazel run` the new target.\n5. Define a new module in `MODULE.bazel` pointing to the Bazel `*.json` lock file:\n\n  ```python\n  cpan = use_extension(\"@rules_perl//perl/cpan:extensions.bzl\", \"cpan\")\n  cpan.install(\n      name = \"cpan\",\n      lock = \"//perl/cpan/3rdparty:cpanfile.snapshot.lock.json\",\n  )\n  use_repo(\n      cpan,\n      \"cpan\",\n  )\n  ```\n\n### Dependencies\n\nOnce the `cpan` module extension is defined, dependencies will be available through the name given to the module.\nUsing the example in the steps above, dependencies can be accessed through `@cpan//...`. (e.g. `@cpan//:DateTime`).\n\nNote that [`xs`](https://perldoc.perl.org/perlxs) dependencies are currently not supported by the `cpan` extension module.\n\n### Simple Pure Perl Example\n\nDownloaded and unpacked: [Test::Mock::Simple](https://metacpan.org/pod/Test::Mock::Simple)\n\nThis modules was chosen because it has no dependencies and is pure Perl.\n\nMoved the required file to `examples/cpan/Test-Mock-Simple-0.10/lib`\n\n**NOTE:** this location has been chosen so you can compare what is in the tar vs what as actually needed.  This is a *bad* location!  It would be better to be in `cpan/lib`.\n\nCreate a target for the module in your BUILD file (which resides in the `cpan` directory):\n\n```python\nperl_library(\n    name = \"TestMockSimple\",\n    srcs = [\"Test-Mock-Simple-0.10/lib/Test/Mock/Simple.pm\"],\n)\n```\n\nNow you can specify it as a dependency to any script that requires that module:\n\n```python\n    env = {\n        \"PERL5LIB\": \"examples/cpan/Test-Mock-Simple-0.10/lib\",\n    },\n    deps = [\"//examples/cpan:TestMockSimple\"],\n```\n\n**NOTE**: at this time you need to provide the directory that Perl needs to add to @INC.\n\n### PERL5LIB includes\n\n`perl_binary` (and `perl_test`) sets up the `PERL5LIB` environment variable with values for all `perl_library` dep's `includes`.\nThe default includes are `[\".\", \"lib\"]`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbazel-contrib%2Frules_perl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbazel-contrib%2Frules_perl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbazel-contrib%2Frules_perl/lists"}