2016-11-05 19:14:19 +00:00
|
|
|
# perl
|
|
|
|
|
|
|
|
> The Perl 5 language interpreter.
|
2019-05-29 14:53:42 +01:00
|
|
|
> More information: <https://www.perl.org>.
|
2016-11-05 19:14:19 +00:00
|
|
|
|
2023-10-24 02:25:09 +01:00
|
|
|
- Print lines from `stdin` [m/] matching regex1 and case insensitive [/i] regex2:
|
2016-11-05 19:14:19 +00:00
|
|
|
|
2023-10-22 20:10:24 +01:00
|
|
|
`perl -n -e 'print if m/{{regex1}}/ and m/{{regex2}}/i'`
|
2016-11-05 19:14:19 +00:00
|
|
|
|
2023-10-22 20:10:24 +01:00
|
|
|
- Say [-E] first match group, using a regexp, ignoring space in regex [/x] :
|
2016-11-05 19:14:19 +00:00
|
|
|
|
2023-10-22 20:10:24 +01:00
|
|
|
`perl -n -E 'say $1 if m/{{before}} ( {{group_regex}} ) {{after}}/x'`
|
2016-11-05 19:14:19 +00:00
|
|
|
|
2023-10-22 20:10:24 +01:00
|
|
|
- [-i]n-place, with backup, [s/] substitute all occurrence [/g] of regex with replacement:
|
2016-11-05 19:14:19 +00:00
|
|
|
|
2023-10-22 20:10:24 +01:00
|
|
|
`perl -i'.bak' -p -e 's/{{regex}}/{{replacement}}/g' {{path/to/files}}`
|
2016-11-05 19:14:19 +00:00
|
|
|
|
2023-10-22 20:10:24 +01:00
|
|
|
- Use perl's inline documentation, some pages also available via man on linux:
|
2016-11-05 19:14:19 +00:00
|
|
|
|
2023-10-22 20:10:24 +01:00
|
|
|
`perldoc perlrun ; perldoc module ; perldoc -f splice; perldoc -q perlfaq1`
|