Prism.languages.perl = { 'comment': [ { // POD pattern: /((?:^|\n)\s*)=\w+[\s\S]*?=cut.*/g, lookbehind: true }, { pattern: /(^|[^\\$])#.*?(\r?\n|$)/g, lookbehind: true } ], // TODO Could be nice to handle Heredoc too. 'string': [ // q/.../ /\b(?:q|qq|qx|qw)\s*([^a-zA-Z0-9\s\{\(\[<])(\\?.)*?\s*\1/g, // q a...a /\b(?:q|qq|qx|qw)\s+([a-zA-Z0-9])(\\?.)*?\s*\1/g, // q(...) /\b(?:q|qq|qx|qw)\s*\(([^()]|\\.)*\s*\)/g, // q{...} /\b(?:q|qq|qx|qw)\s*\{([^{}]|\\.)*\s*\}/g, // q[...] /\b(?:q|qq|qx|qw)\s*\[([^[\]]|\\.)*\s*\]/g, // q<...> /\b(?:q|qq|qx|qw)\s*<([^<>]|\\.)*\s*>/g, // "...", '...', `...` /("|'|`)(\\?.)*?\1/g ], 'regex': [ // m/.../ /\b(?:m|qr)\s*([^a-zA-Z0-9\s\{\(\[<])(\\?.)*?\s*\1[msixpodualgc]*/g, // m a...a /\b(?:m|qr)\s+([a-zA-Z0-9])(\\?.)*?\s*\1[msixpodualgc]*/g, // m(...) /\b(?:m|qr)\s*\(([^()]|\\.)*\s*\)[msixpodualgc]*/g, // m{...} /\b(?:m|qr)\s*\{([^{}]|\\.)*\s*\}[msixpodualgc]*/g, // m[...] /\b(?:m|qr)\s*\[([^[\]]|\\.)*\s*\][msixpodualgc]*/g, // m<...> /\b(?:m|qr)\s*<([^<>]|\\.)*\s*>[msixpodualgc]*/g, // s/.../.../ /\b(?:s|tr|y)\s*([^a-zA-Z0-9\s\{\(\[<])(\\?.)*?\s*\1\s*((?!\1).|\\.)*\s*\1[msixpodualgcer]*/g, // s a...a...a /\b(?:s|tr|y)\s+([a-zA-Z0-9])(\\?.)*?\s*\1\s*((?!\1).|\\.)*\s*\1[msixpodualgcer]*/g, // s(...)(...) /\b(?:s|tr|y)\s*\(([^()]|\\.)*\s*\)\s*\(\s*([^()]|\\.)*\s*\)[msixpodualgcer]*/g, // s{...}{...} /\b(?:s|tr|y)\s*\{([^{}]|\\.)*\s*\}\s*\{\s*([^{}]|\\.)*\s*\}[msixpodualgcer]*/g, // s[...][...] /\b(?:s|tr|y)\s*\[([^[\]]|\\.)*\s*\]\s*\[\s*([^[\]]|\\.)*\s*\][msixpodualgcer]*/g, // s<...><...> /\b(?:s|tr|y)\s*<([^<>]|\\.)*\s*>\s*<\s*([^<>]|\\.)*\s*>[msixpodualgcer]*/g, // /.../ /\/(\[.+?]|\\.|[^\/\r\n])*\/[msixpodualgc]*(?=\s*($|[\r\n,.;})&|\-+*=~<>!?^]|(lt|gt|le|ge|eq|ne|cmp|not|and|or|xor|x)\b))/g ], // FIXME Not sure about the handling of ::, ', and # 'variable': [ // ${^POSTMATCH} /[&*\$@%]\{\^[A-Z]+\}/g, // $^V /[&*\$@%]\^[A-Z_]/g, // ${...} /[&*\$@%]#?(?=\{)/, // $foo /[&*\$@%]#?((::)*'?(?!\d)[\w$]+)+(::)*/ig, // $1 /[&*\$@%]\d+/g, // $_, @_, %! /[\$@%][!"#\$%&'()*+,\-.\/:;<=>?@[\\\]^_`{|}~]/g ], 'filehandle': { // <>, , _ pattern: /<(?!=).*>|\b_\b/g, alias: 'symbol' }, 'vstring': { // v1.2, 1.2.3 pattern: /v\d+(\.\d+)*|\d+(\.\d+){2,}/g, alias: 'string' }, 'function': { pattern: /sub [a-z0-9_]+/ig, inside: { keyword: /sub/ } }, 'keyword': /\b(any|break|continue|default|delete|die|do|else|elsif|eval|for|foreach|given|goto|if|last|local|my|next|our|package|print|redo|require|say|state|sub|switch|undef|unless|until|use|when|while)\b/g, 'number': /(\n|\b)-?(0x[\dA-Fa-f](_?[\dA-Fa-f])*|0b[01](_?[01])*|(\d(_?\d)*)?\.?\d(_?\d)*([Ee]-?\d+)?)\b/g, 'operator': /-[rwxoRWXOezsfdlpSbctugkTBMAC]\b|[-+*=~\/|&]{1,2}|<=?|>=?|\.{1,3}|[!?\\^]|\b(lt|gt|le|ge|eq|ne|cmp|not|and|or|xor|x)\b/g, 'punctuation': /[{}[\];(),:]/g };