m operator in Perl is used to match a pattern within the given text. The string passed to m operator can be enclosed within any character which will be used as a delimiter to regular expressions.
To print this matched pattern and the remaining string, m operator provides various operators which include $, which contains whatever the last grouping match matched.
$& – contains the entire matched string
$` – contains everything before the matched string
$’ – contains everything after the matched string
0 on failure and 1 on success
Before: Geeks f Matched: or g After: eeks is the best
Before: Welcome Matched: to Ge After: eksForGeeks
- Perl | qw Operator
- Perl | next operator
- Perl | q operator
- Perl | qq operator
- Perl | lt operator
- Perl | tr Operator
- Perl | ge operator
- Perl | eq operator
- Perl | ne operator
- Perl | le operator
- Perl | y Operator
- Perl | cmp Operator
- Perl | gt operator
- Perl | redo operator
- Perl | print operator
- Perl | substitution Operator
- Perl Tutorial - Learn Perl With Examples
- Perl | Basic Syntax of a Perl Program
- Perl vs C/C++
- Use of print() and say() in Perl
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.