Perl Home
PERL Functions
© 2011 TutorialsPoint.COM
|
PERL m// Operator
Syntax
Definition and Usage
This match operator is used to match any keyword in given expression. Parentheses after initial m can be any character and will be used to delimit the regular expression statement.
Regular expression variables include $, which contains whatever the last grouping match matched; $&, which contains the entire matched string; $`, which contains everything before the matched string; and $', which contains everything after the matched string.
Return Value
0 on failure
1 on success
Example
Try out following example:
#!/usr/bin/perl -w
$string = "The food is in the salad bar";
$string =~ m/foo/;
print "Before: $`\n";
print "Matched: $&\n";
print "After: $'\n";
|
It will produce following results:
Before: The
Matched: foo
After: d is in the salad bar
| |
|

|
|
|