/ ^ # start (?:([\$\@\*\%])|<) # leading sigil or < (\w+) # name (?(?{$1}) |> ) # if there was a leading sigil, match nothing; # otherwise, match > $ # end /x; #### / ^ # start ([\$\@\*\%<]) # sigil (\w+) # name (?(?{$1 eq '<'}) >| ) # if the sigil is a '<', match the end; # otherwise match nothing $ # end /x;