if (m{^(.*)/(tp_\w+)}i) { my ( $pathPrefix, $tpname ) = ( $1 ? ( $1, $2 ) : ( '.', $_ ) ); # etc... }