#!/usr/bin/perl -w
my $var = "welcome to groad.net";
if (/\bto\b/) {
print "match\n";
} else {
print "not match\n";
}
if ($var =~ /\bwelcome\b/) {
print "match\n";
} else {
print "not match\n";
}
# ./bind.pl
Use of uninitialized value $_ in pattern match (m//) at ./bind.pl line 5.
not match
match
#!/usr/bin/perl -w
my $var = "welcome to groad.net";
if (/\bto\b/) {
print "match\n";
} else {
print "not match\n";
}
if ($var =~ /\bwelcome\b/) {
print "match\n";
} else {
print "not match\n";
}
# ./bind2.pl
Do you like perl?yes
yes, you like perl.
# ./bind2.pl
Do you like perl?no
you do not like perl.
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |