# Example 1
#
$_ = "I logged in as brusimm and found that I had email."; # Test string
if (/brus/) { # Pattern: brus
print "There, our pattern showed up in our string.\n" ; # Tell user
} else { # or
print "No match in our string for our pattern.\n"; # As you'll see...
} # end
####
while (<>) {
if (/brus/) {
print $_;
}
}
##
##
# Example 2
#
$_ = "I logged in as brusimm and found that I had email."; # Test string
if (/but|brus/) { # PatternS: but or brus
print "There, our pattern showed up in our string.\n" ; # Tell user
} else {
print "No match in our string for our pattern.\n"; # As you'll see...
} # end
##
##
# Example 3
#
$_ = "I logged in as bruuuusimm and found that I had email."; # Our test sentence
if (/brus/) { # Our pattern of brus
print "There, brus showed up.\n" ; # if pattern is found, print it!
} # end
##
##
# example 4
#
$_ = "I logged into bruuuusimm and saw I had email.\n"; # original error
print $_ ; # printing proof of error
if (s/bru*s/brus/) { # fixing it
print $_ ; # proving we fixed it.
}
##
##
# example 5
#
$_ = "I logged into brusimm and saw I had email.\n";
if (/a/) {
print $_ ;
}
##
##
# example 6
#
print "Hello" . ' ' . "world"; #Same as 'Hello world'
##
##
# example 7
#
$_ = "I logged into brusimm and saw I had FIVE email.\n";
if (/[xyz]/) {
print $_ ;
}
#
##
##
# example 8
#
$_ = "I make a black pencil line.\n";
if (/[q-zQ-Z]/) {
print $_ ;
}