Each element looks like (REGEXP . FUNCTION) or (MATCH-FUNCTION . FUNCTION).
It is one of the methods used by the set-auto-mode function. This tries each element of the alist in turn and uses the first match. If RegularExpression REGEXP matches the text in the buffer, or calling MATCH-FUNCTION returns non-nil, then FUNCTION will be called. If the selected FUNCTION is nil, then it is not called and the rest of the alist is ignored. Before applying the alist, the buffer is narrowed to its first few characters, as determined by the
‘magic-mode-regexp-match-limit’ variable (default 4000).
What’s a good value for Perl? – DenisHowe