#! /usr/bin/perl
use strict;
use warnings;
#my @strict_pragma = qw ( a b c);
#print $strict_pragma[0];
print "
----------------------------------_delimiter_match_http://--------------------------
";
$_ = "https://www.cnblogs.com/books2read/";
if(m%http[s]*://%){
print "unpacking_@_ * 1
";
}
print "
----------------------------------_delimiter_match_http://--------------------------
";
print "
----------------------------------_optional_modifiers_----------------------------------------------------------------------------------------------
";
print "unnecessary subscripting:";
chomp($_ = <STDIN>);
if(/yes/i){
print "array-ref values.
"
}
print "
----------------------------------_/s--------------------------
";
$_ = " naming conventions references to slice factoring
slicing anonymous attribute demolition.";
if(/conventions.*demolition/s){
print "string mentions demolition after conventions.
";
}
print "
----------------------------------_/s--------------------------
";
print "
----------------------------------_optional_modifiers_----------------------------------------------------------------------------------------------
";
print "
----------------------------------_/x--------------------------
";
$_ = "demolition array-ref values. 2";
if(/
-? # one optional minus sign
d+ # one or more digits before the decimal point
.? # an optional decimal point
d* # some optional digits after the decimal point
/x){
print "match *1.
"
}
$_ = "3415";
if(/
-? # one optional minus sign
d+ # one or more digits before the decimal point
.? # an optional decimal point
d* # some optional digits after the decimal point
/x){
print "match *2.
"
}
print "
----------------------------------_/x--------------------------
";
print "
----------------------------------_combining_opiton_modfiers--------------------------
";
$_ = " naming conventions references to slice factoring
slicing anonymous attribute Demolition.";
if(/conventions.*demolition/si){
print "string mentions demolition after conventions. match*3
";
}
print "
----------------------------------_combining_opiton_modfiers--------------------------
";
print "
----------------------------------2222_combining_opiton_modfiers--------------------------
";
$_ = " naming conventions references to slice factoring
slicing anonymous attribute Demolition.";
if(/
conventions
.*
demolition
/six){
print "string mentions demolition after conventions. match*4
";
}
print "
----------------------------------222_combining_opiton_modfiers--------------------------
";
print "
----------------------------------_anchors_--------------------------
";
$_ = "ATTR marker,";
my $contextual;
if(/s+(w+),/){
print "Caret anchor works.
";
$contextual = $1;
}
print "
----------------------------------_anchors_--------------------------
";
print "
----------------------------------_persistence_of_memory--------------------------
";
my $precedence = "!!!";
$precedence =~ /(w+)/;
print "precedence's word was $1 ... or was it?
";
# to prevent the matching variable override, you can store it in a defined variable
print $contextual;
print "
----------------------------------_persistence_of_memory--------------------------
";
print "
----------------------------------_automatic_match_variable--------------------------
";
$_ = "ATTR marker,";
if(/s+(w+),/){
print "That actually matched '$&'.
";
}
print "That was ($`)($&)($').
";
print ($`);
print "
";
print '$&'."
";
print $'."
";
print "
";
print '$contextual';
print "
";
print $contextual;
print "
----------------------------------_automatic_match_variable--------------------------
";
print "
----------------------------------_general_quantifiers--------------------------
";
$_ = ",,,,,,";
if(/,{5}/){
print "match * 8
";
}
print "
----------------------------------_general_quantifiers--------------------------
";
print "
----------------------------------_pattern_test_program--------------------------
";
$_ = "test, it's!";
if(/w+,s+w+'/){
print "matched: <$`><$&><$'>|
";
}
print "
----------------------------------_pattern_test_program--------------------------
";
print "
----------------------------------_ch8_Q1--------------------------
";
$_ = "beforematchafter";
if(/match/){
print "matched: <$`><$&><$'>|
";
}
print "
----------------------------------_ch8_Q1--------------------------
";
print "
----------------------------------_ch8_Q2--------------------------
";
$_ = "beforematcha? fter";
if(/w+a/){
print "matched: <$`><$&><$'>|
";
}
print "
----------------------------------_ch8_Q2--------------------------
";