$catreg = "^(<[A-Za-z0-9]+>)*
##
if ( m!$catreg! ) {
####
m!^(<[A-Za-z0-9]+>)*(<[A-Za-z0-9]+>)*([A-Za-z0-9]+)!
##
##
# the lack of a $var =~ here indicates
# that we are matching against $_
m # this is a match regex
! # we define the extent of the regex using a !
^ # starting at the begining of the string
( # grouping and capturing opening bracket
< # matches this charachter '<'
[A-Za-z0-9]+ # match any number of alphanumerics in a row
> # match a literal '>'
) # closing bracket
# the match between brackets captures to $1
* # accept 0 or more of the preceeding stuff
# but note only first match captured into $1
# within the brackets
# match a literal ''
(<[A-Za-z0-9]+>)* # same as first but captures into $2
# the first '' sequence
([A-Za-z0-9]+) # matches sequential alphanumerics and
# captures all into $3
! # end of regex
##
##
$catreg = "^(<[A-Za-z0-9]+>)*(<[A-Za-z0-9]+>)*([A-Za-z0-9]+)";
$_="foo";
if ( m!$catreg! ) {
print "Matched \$1:$1 \$2$2 \$3$3\n";
} else {
print "No Match\n";
}
##
##
$_='foo
blahbar
more blah';
while (m!(.*?)
!ig) {
print "Found $1\n";
}