2025-03-14 21:59:59 -06:00
|
|
|
# perl
|
|
|
|
|
|
|
|
|
|
> The Perl 5 language interpreter.
|
|
|
|
|
> More information: <https://www.perl.org>.
|
|
|
|
|
|
2025-09-14 18:48:49 -06:00
|
|
|
- Print lines from `stdin` [m/] matching `regex1` and case insensitive [/i] `regex2`:
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
`perl -n -e 'print if m/{{regex1}}/ and m/{{regex2}}/i'`
|
|
|
|
|
|
2025-09-14 18:48:49 -06:00
|
|
|
- Say [-E] first match group, using a `regex`, ignoring space in `regex` [/x]:
|
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-09-14 18:48:49 -06:00
|
|
|
- [-i]n-place, with backup, [s/] substitute all occurrence [/g] of `regex` with replacement:
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
`perl -i'.bak' -p -e 's/{{regex}}/{{replacement}}/g' {{path/to/files}}`
|
|
|
|
|
|
|
|
|
|
- Use perl's inline documentation, some pages also available via manual pages on Linux:
|
|
|
|
|
|
|
|
|
|
`perldoc perlrun ; perldoc module ; perldoc -f splice; perldoc -q perlfaq1`
|