1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-04-23 03:22:08 +02:00
tldr/pages/common/perl.md
Lena 9ced683c99
style-guide: add guidelines for standard streams; fix remaining pages (#11196)
* readonly, {un,}compress, zbarcam: use proper syntax for IO streams

* style-guide: add guidelines for standard streams

* duckdb, perl: add backticks around stdin and stdout
2023-10-24 06:55:09 +05:30

701 B

perl

The Perl 5 language interpreter. More information: https://www.perl.org.

  • Print lines from stdin [m/] matching regex1 and case insensitive [/i] regex2:

perl -n -e 'print if m/{{regex1}}/ and m/{{regex2}}/i'

  • Say [-E] first match group, using a regexp, ignoring space in regex [/x] :

perl -n -E 'say $1 if m/{{before}} ( {{group_regex}} ) {{after}}/x'

  • [-i]n-place, with backup, [s/] substitute all occurrence [/g] of regex with replacement:

perl -i'.bak' -p -e 's/{{regex}}/{{replacement}}/g' {{path/to/files}}

  • Use perl's inline documentation, some pages also available via man on linux:

perldoc perlrun ; perldoc module ; perldoc -f splice; perldoc -q perlfaq1