Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Perl app example

A Perl stock CLI split into three packages. Every target runs on the relocatable Perl 5.40 that rules_perl pins, with nothing installed on the host.

PackageRole
inventoryInventory::Item and Inventory::Ledger, a stock ledger with a per-item limit
reportUnit table from data/units.csv read through runfiles, and CSV output through Text::CSV
clistockctl command line and a launcher test
bazel build //examples/perl-app/...
bazel test //examples/perl-app/...
bazel run //examples/perl-app/cli:stockctl -- "add 2 dozen pears" "count pears"
bazel test //examples/perl-app/... --//examples/perl-app/cli:limit=144

The run prints 24, 24 and the report name,units / pears,24. A command that fails prints error: ... and exits 1. The limit flag selects the per-item limit through select() on env, and the launcher test follows it.

Text::CSV 2.06 comes from CPAN through the rules_perl cpan extension. Its lock is third_party/cpanfile.snapshot.lock.json, and every distribution carries a sha256. Text::CSV runs on its pure-Perl Text::CSV_PP backend. To change the pin, edit third_party/cpanfile and run bazel run //examples/perl-app/third_party:compiler.

PlatformStatus
linux_x86_64Qualified
linux_arm64, macos_arm64, windows_x86_64Not qualified
windows_arm64Unsupported