# From: Schwartz & Phoenix: Learning Perl, 3rd Ed (The Llama), pp. 103
use strict;
while (<>) {
chomp;
if (/[en]/) {
print "Matched: |$`<$&>$'|\n";
} else {
print "No match.\n";
}
}
####
English
French
Spanish
German
Aramaic
Arabic
##
##
Matched: |Eglish|
Matched: |Frnch|
Matched: |Spaish|
Matched: |Grman|
No match.
No match.
No match.
##
##
No match.
Matched: |Frch|
No match.
No match.
No match.
No match.
No match.
##
##
# From: Schwartz & Phoenix: Learning Perl, 3rd Ed (The Llama), pp. 103
use strict;
while (<>) {
chomp;
if (/en/) {
print "Matched: |$`<$&>$'|\n";
} else {
print "No match.\n";
}
}