2025-03-14 21:59:59 -06:00
|
|
|
# perl
|
|
|
|
|
|
|
|
|
|
> The Perl 5 language interpreter.
|
2025-12-16 10:20:31 -07:00
|
|
|
> See also: `perldoc`.
|
|
|
|
|
> More information: <https://perldoc.perl.org/perl>.
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
- Print lines from `stdin` [m]atching `regex1` and case [i]nsensitive `regex2`:
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`perl -n -e 'print if m/regex1/ and m/regex2/i'`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
- Say ([-E]) first match group, using a `regex`, ignoring space ([x]) in `regex`:
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-07-24 22:27:13 -06:00
|
|
|
`perl -n -E 'say $1 if m/{{before}} ( {{group_regex}} ) {{after}}/x'`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
- [i]n-place, with backup, [s]ubstitute all occurrence ([g]) of `regex` with a replacement:
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`perl -i'.bak' -p -e 's/regex/{{replacement}}/g' {{path/to/files}}`
|