What does it mean: "Trailing \ in regex m/\\\/ at ...

F

fl

Hi,
I am learning an example, see below part. I find that there is a
special message from the running of the example when I input three
\'s (\\\). It says was not found when I input two, four or other
number \.

My question is: 1. Why it only has this output for three \. 2. What is
the meaning: "Trailing \ in regex m/\\\/ at matchtest.plx line 13,
<STDIN> line 1. Thanks.





........
#!/usr/bin/perl
# matchtest.plx
use warnings;
use strict;

$_ = q("I wonder what the Entish is for 'yes' and 'no'," he thought.);
# Tolkien, Lord of the Rings

print "Enter some text to find: ";
my $pattern = <STDIN>;
chomp($pattern);

if (/$pattern/) {
print "The text matches the pattern '$pattern'.\n";
} else {
print "'$pattern' was not found.\n";
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,738
Latest member
JinaMacvit

Latest Threads

Top