# Coming from another language You already know how to program. You reach for a hash, a loop, a function, a regex without thinking - in some other language. These guides teach Perl by mapping what you already do onto how Perl does it, one construct at a time. Your dictionary is a Perl hash; here is the syntax, and here is the one place the analogy leaks. Each guide assumes you are **fluent in the source language and new to Perl**. It does not teach the source language back to you. It teaches the Perl side of each pairing: the syntax, the idiom, and - most useful of all - the gotcha that the surface similarity hides. Every guide in this series covers the **same topics in the same order**, so the mapping is comparable across languages and the series grows cleanly as new languages are added. The order moves from what every language shares (variables, strings, numbers) through Perl's distinctive shapes (sigils, the array/hash split, and **context** - the one idea no other language has), into structure (subroutines, references, modules, objects), and out through the working surface (regex, I/O, error handling, idioms), ending with a per-language collection of the traps that actually bite. ## Which guide you want - [Python to Perl](python) - sigils where Python has none, the array/hash split where Python has `list` and `dict`, comprehensions rewritten as `map`/`grep`, and the context concept Python has no word for. - [PHP to Perl](php) - you already have `$`, but in Perl it shifts by access, PHP's one `array` splits into `@array` and `%hash`, and `.` versus `+` (and `==` versus `eq`) stop being interchangeable. - [Ruby to Perl](ruby) - blocks become Perl blocks and closures, method-calls-on-everything become plain functions, and Ruby's "only `nil` and `false` are falsy" inverts into Perl's truthiness. - [Lua to Perl](lua) - the one table type splits into `@array` and `%hash`, indexing turns 0-based, Lua patterns become real regex, and multiple-return-values are your bridge to Perl's context. - [Sed to Perl](sed) - the same `s///` you already know, sed's `y///` becomes `tr///`, address ranges become the `/a/ .. /b/` flip-flop, and the hold space becomes an ordinary Perl variable. - [Awk to Perl](awk) - Perl grew out of awk, so almost everything maps directly: fields become `@F` and `split`, `NR` becomes `$.`, associative arrays become hashes, and `BEGIN`/`END` keep their names. - [Shell to Perl](shell) - for when a shell script outgrew itself: `$(cmd)` becomes `qx{}`, the `[ ]`/`-f` file tests carry straight over, and the `${var#...}` parameter expansions become real regex. - [Tcl to Perl](tcl) - a carry-over for Tcl maintainers: `set x` becomes `my $x`, `[expr {}]` disappears into native operators, lists and `array` become Perl arrays and hashes, and `regsub` becomes `s///`. ## The one concept to read first If you read only one section of whichever guide matches your background, read **Context**. Every other language in this series collapses a collection to a count, a first element, or a boolean with explicit syntax (`len(x)`, `x[0]`, `bool(x)`). Perl does it through *context*: the same expression yields a list in one place and a single scalar in another, decided by where you wrote it. It is the source of most "why did my array become the number 3?" confusion, and once it clicks the rest of Perl falls into place. ## A note on the runtime These guides target `pperl`, a faithful Rust reimplementation of Perl 5.42. Every Perl example that runs as a script was executed on `pperl` and shows real output. The text-processing guides (sed, awk, shell) also show the classic `perl -ne`/`perl -pe` one-liner forms, which are the idiomatic Perl equivalent; the implicit-loop switches behind them are not yet recognised by this `pperl` build, so those one-liners are shown for reference and paired with an explicit-loop script you can run today. ```{toctree} :maxdepth: 1 :hidden: python php ruby lua sed awk shell tcl ```