Uses subroutine and regex pattern variable (qr).