/usr/share/highlight/langDefs/perl.lang is in highlight-common 3.41-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | Description="Perl"
Keywords={
{ Id=1,
List={"if", "else", "elsif", "unless", "given", "when", "default", "while", "for", "foreach",
"do", "until", "continue", "return", "last", "next", "redo", "goto", "break", "exit", "sub",
"package", "use", "no", "dump", "require", "BEGIN", "CHECK", "INIT", "END", "UNITCHECK",
"NEXT", "loop", "class", "in" },
},
{ Id=2,
Regex=[[ [$@%]\#?\w+ ]],
},
{ Id=3,
List={"defined", "undef", "eq", "ne", "lt", "gt", "ge", "le", "cmp", "not",
"and", "or", "xor", "bless", "ref", "my", "our", "local", "state", "chomp",
"chop", "chr", "crypt", "index", "rindex", "lc", "lcfirst", "length", "ord",
"pack", "print", "printf", "sprintf", "substr", "uc",
"ucfirst", "pos", "quotemeta", "split", "study", "abs", "atan2", "cos",
"exp", "hex", "int", "log", "oct", "rand", "sin", "sqrt", "srand", "splice",
"unshift", "shift", "push", "pop", "join", "reverse", "grep", "map", "sort",
"unpack", "pack", "delete", "each", "exists", "keys",
"values", "syscall", "dbmopen", "dbmclose", "binmode", "close", "closedir",
"eof", "fileno", "getc", "stat", "lstat", "read", "readdir", "readline", "pipe",
"rewinddir", "say", "select", "tell", "telldir", "write", "fcntl", "flock",
"ioctl", "open", "opendir", "seek", "seekdir",
"sysopen", "sysread", "sysseek", "syswrite", "truncate", "chdir", "chmod",
"chown", "chroot", "glob", "link", "mkdir", "readlink", "rename", "rmdir", "symlink",
"umask", "unlink", "utime", "caller", "die", "wantarray", "vec", "alarm",
"exec", "fork", "getpgrp", "getppid", "getpriority", "kill", "pipe", "setpgrp",
"setpriority", "sleep", "system", "times", "wait", "waitpid", "accept", "bind",
"connect", "getpeername", "getsockname",
"getsockopt", "listen", "recv", "send", "setsockopt", "shutdown", "socket",
"socketpair", "msgctl", "msgget", "msgrcv", "msgsnd", "semctl", "semget",
"semop", "shmctl", "shmget", "shmread", "shmwrite", "gethostent", "getnetent",
"getprotoent", "getservent", "setpwent",
"setgrent", "sethostent", "setnetent", "setprotoent", "setservent",
"endpwent", "endgrent", "endhostent", "endnetent", "endprotoent", "endservent",
"gethostbyaddr", "gethostbyname", "getnetbyaddr", "getnetbyname",
"getprotobyname", "getprotobynumber", "getservbyname",
"getservbyport", "getpwuid", "getpwnam", "getgrgid", "getgrnam", "getlogin",
"getpwent", "getgrent", "gmtime", "localtime", "time", "warn", "formline",
"reset", "scalar", "prototype", "lock", "tied", "untie", "qq", "qx", "eval" },
},
{ Id=4,
Regex=[[->([a-zA-Z0-9_]+)]],
Group=1,
},
--# Still only covers more common usage but by far not all
-- see OnStateChange below
{ Id=4,
Regex=[[\/.*?\/[msixpodualgc]*|m\/.*?\/[msixpodualgc]*|qr\/.*?\/[msixpodual]*|s\/.*?\/.*?\/[msixpodualgcer]*|(?:tr|y)\/.*?\/.*?\/[cdsr]*|m!.*?![msixpodualgc]*|qr!.*?![msixpodual]*|s!.*?!.*?![msixpodualgcer]*|(?:tr|y)!.*?!.*?![cdsr]*|m\?.*?\?[msixpodualgc]*|m\{.*?\}[msixpodualgc]*|qr\{.*?\}[msixpodual]*|s\{.*?\}\s*\{.*?\}[msixpodualgcer]*|(?:tr|y)\{.*?\}\s*\{.*?\}[cdsr]*]],
Group=0
},
{ Id=4,
Regex=[[q[qxwr]?\{|qw\(]]
},
}
-- hereDoc opening delimiter, see OnStateChange to handle end of string
-- do not allow digits as heredoc delimiters
Strings={
Delimiter=[=["|'|`|<<["']?[[:alpha:]]+["']?]=],
Interpolation=[[ [@\$%]\w+ ]],
}
IgnoreCase=false
Comments={
{ Block=true,
Nested=false,
Delimiter = { [[(?:^=pod|^=head[1234]|^=over|^=item|^=back|^=begin|^=end|^=for|^=encoding)]], [[^=cut\s*\Z]] } },
{ Block=false,
Delimiter= { [[(?<!\\)#]] },
},
}
Operators=[[\(|\)|\[|\]|\{|\}|\,|\;|\:|\&|<|>|\!|~|\=|\/|\*|\+|\-|\$|\.|\^|\~|\%|\|]]
-- fix recognition of $ and other Perl perversions
function OnStateChange(oldState, newState, token, groupID)
-- resolve issue with regex expression which spans strings like "</i>" + VAR + "</i>"
if string.sub(token,1,1)=="/" and oldState==HL_STRING and newState==HL_KEYWORD and groupID == 4 then
return HL_REJECT
end
if (string.sub(token,1,1) =="$" or string.sub(token,1,1) =="@" or string.sub(token,1,1) =="%") and oldState==HL_STRING and newState==HL_KEYWORD then
return HL_INTERPOLATION
end
--recognize hereDoc multine strings
--do not clear hereDoc if token is ",' or `
if (oldState==HL_STANDARD or oldState==HL_STRING) and newState==HL_STRING and not string.find("\"'`", token) then
hereDoc = string.match(token, "<<'?\"?(%a+)" )
end
if oldState==HL_STRING and token==hereDoc then
hereDoc = nil
return HL_STRING_END
end
-- fix issue in CGI.pm testcase (line 1060 ff)
if oldState~=HL_STRING then
qString=0
end
if newState==HL_KEYWORD and token=="q{" then
qString=1
return HL_STRING
end
if newState==HL_KEYWORD and token=="qw(" then
qString=2
return HL_STRING
end
if oldState==HL_STRING and qString==1 and token=="}" then
qString=0
return HL_STRING_END
end
if oldState==HL_STRING and qString==2 and token==")" then
qString=0
return HL_STRING_END
end
return newState
end
|