1<?php
2/*************************************************************************************
3 * perl.php
4 * --------
5 * Author: Andreas Gohr (andi@splitbrain.org), Ben Keen (ben.keen@gmail.com)
6 * Copyright: (c) 2004 Andreas Gohr, Ben Keen (http://www.benjaminkeen.org/), Nigel McNie (http://qbnz.com/highlighter/)
7 * Release Version: 1.0.9.1
8 * Date Started: 2004/08/20
9 *
10 * Perl language file for GeSHi.
11 *
12 * CHANGES
13 * -------
14 * 2008/06/22 (1.0.8)
15 *   -  Added support for system calls in backticks (Corley Kinnane)
16 * 2008/05/23 (1.0.7.22)
17 *   -  Added description of extra language features (SF#1970248)
18 *   -  Added comment_regexp for predefined variables
19 * 2008/02/15 (1.003)
20 *   -  Fixed SF#1891630 with placebo patch
21 * 2006/01/05 (1.0.2)
22 *   -  Used hardescape feature for ' strings (Cliff Stanford)
23 * 2004/11/27 (1.0.1)
24 *   -  Added support for multiple object splitters
25 * 2004/08/20 (1.0.0)
26 *   -  First Release
27 *
28 * TODO (updated 2004/11/27)
29 * -------------------------
30 * * LABEL:
31 * * string comparison operators
32 *
33 *************************************************************************************
34 *
35 *     This file is part of GeSHi.
36 *
37 *   GeSHi is free software; you can redistribute it and/or modify
38 *   it under the terms of the GNU General Public License as published by
39 *   the Free Software Foundation; either version 2 of the License, or
40 *   (at your option) any later version.
41 *
42 *   GeSHi is distributed in the hope that it will be useful,
43 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
44 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
45 *   GNU General Public License for more details.
46 *
47 *   You should have received a copy of the GNU General Public License
48 *   along with GeSHi; if not, write to the Free Software
49 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
50 *
51 ************************************************************************************/
52
53$language_data = array (
54    'LANG_NAME' => 'Perl',
55    'COMMENT_SINGLE' => array(1 => '#'),
56    'COMMENT_MULTI' => array(
57        '=back' => '=cut',
58        '=head' => '=cut',
59        '=item' => '=cut',
60        '=over' => '=cut',
61        '=begin' => '=cut',
62        '=end' => '=cut',
63        '=for' => '=cut',
64        '=encoding' => '=cut',
65        '=pod' => '=cut'
66        ),
67    'COMMENT_REGEXP' => array(
68        //Regular expressions
69        2 => "/(?<=[\\s^])(s|tr|y)\\/(?:\\\\.|(?!\n)[^\\/\\\\])+\\/(?:\\\\.|(?!\n)[^\\/\\\\])*\\/[msixpogcde]*(?=[\\s$\\.\\;])|(?<=[\\s^(=])(m|q[qrwx]?)?\\/(?:\\\\.|(?!\n)[^\\/\\\\])+\\/[msixpogc]*(?=[\\s$\\.\\,\\;\\)])/iU",
70        //Regular expression match variables
71        3 => '/\$\d+/',
72        //Heredoc
73        4 => '/<<\s*?([\'"]?)([a-zA-Z0-9]+)\1;[^\n]*?\\n.*\\n\\2(?![a-zA-Z0-9])/siU',
74        //Predefined variables
75        5 => '/\$(\^[a-zA-Z]?|[\*\$`\'&_\.,+\-~:;\\\\\/"\|%=\?!@#<>\(\)\[\]])(?!\w)|@[_+\-]|%[!]|\$(?=\{)/',
76        ),
77    'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE,
78    'QUOTEMARKS' => array('"','`'),
79    'HARDQUOTE' => array("'", "'"),            // An optional 2-element array defining the beginning and end of a hard-quoted string
80    'HARDESCAPE' => array('\\\'',),
81        // Things that must still be escaped inside a hard-quoted string
82        // If HARDQUOTE is defined, HARDESCAPE must be defined
83        // This will not work unless the first character of each element is either in the
84        // QUOTEMARKS array or is the ESCAPE_CHAR
85    'ESCAPE_CHAR' => '\\',
86    'KEYWORDS' => array(
87        1 => array(
88            'case', 'do', 'else', 'elsif', 'for', 'if', 'then', 'until', 'while', 'foreach', 'my',
89            'xor', 'or', 'and', 'unless', 'next', 'last', 'redo', 'not', 'our',
90            'reset', 'continue', 'cmp', 'ne', 'eq', 'lt', 'gt', 'le', 'ge',
91            ),
92        2 => array(
93            'use', 'sub', 'new', '__END__', '__DATA__', '__DIE__', '__WARN__', 'BEGIN',
94            'STDIN', 'STDOUT', 'STDERR', 'ARGV', 'ARGVOUT'
95            ),
96        3 => array(
97            'abs', 'accept', 'alarm', 'atan2', 'bind', 'binmode', 'bless',
98            'caller', 'chdir', 'chmod', 'chomp', 'chop', 'chown', 'chr',
99            'chroot', 'close', 'closedir', 'connect', 'cos',
100            'crypt', 'dbmclose', 'dbmopen', 'defined', 'delete', 'die',
101            'dump', 'each', 'endgrent', 'endhostent', 'endnetent', 'endprotoent',
102            'endpwent', 'endservent', 'eof', 'eval', 'exec', 'exists', 'exit',
103            'exp', 'fcntl', 'fileno', 'flock', 'fork', 'format', 'formline',
104            'getc', 'getgrent', 'getgrgid', 'getgrnam', 'gethostbyaddr',
105            'gethostbyname', 'gethostent', 'getlogin', 'getnetbyaddr', 'getnetbyname',
106            'getnetent', 'getpeername', 'getpgrp', 'getppid', 'getpriority',
107            'getprotobyname', 'getprotobynumber', 'getprotoent', 'getpwent',
108            'getpwnam', 'getpwuid', 'getservbyname', 'getservbyport', 'getservent',
109            'getsockname', 'getsockopt', 'glob', 'gmtime', 'goto', 'grep',
110            'hex', 'import', 'index', 'int', 'ioctl', 'join', 'keys', 'kill',
111            'lc', 'lcfirst', 'length', 'link', 'listen', 'local',
112            'localtime', 'log', 'lstat', 'm', 'map', 'mkdir', 'msgctl', 'msgget',
113            'msgrcv', 'msgsnd', 'no', 'oct', 'open', 'opendir',
114            'ord', 'pack', 'package', 'pipe', 'pop', 'pos', 'print',
115            'printf', 'prototype', 'push', 'qq', 'qr', 'quotemeta', 'qw',
116            'qx', 'q', 'rand', 'read', 'readdir', 'readline', 'readlink', 'readpipe',
117            'recv', 'ref', 'rename', 'require', 'return',
118            'reverse', 'rewinddir', 'rindex', 'rmdir', 's', 'scalar', 'seek',
119            'seekdir', 'select', 'semctl', 'semget', 'semop', 'send', 'setgrent',
120            'sethostent', 'setnetent', 'setpgrp', 'setpriority', 'setprotoent',
121            'setpwent', 'setservent', 'setsockopt', 'shift', 'shmctl', 'shmget',
122            'shmread', 'shmwrite', 'shutdown', 'sin', 'sleep', 'socket', 'socketpair',
123            'sort', 'splice', 'split', 'sprintf', 'sqrt', 'srand', 'stat',
124            'study', 'substr', 'symlink', 'syscall', 'sysopen', 'sysread',
125            'sysseek', 'system', 'syswrite', 'tell', 'telldir', 'tie', 'tied',
126            'time', 'times', 'tr', 'truncate', 'uc', 'ucfirst', 'umask', 'undef',
127            'unlink', 'unpack', 'unshift', 'untie', 'utime', 'values',
128            'vec', 'wait', 'waitpid', 'wantarray', 'warn', 'write', 'y'
129            )
130        ),
131    'SYMBOLS' => array(
132        '<', '>', '=',
133        '!', '@', '~', '&', '|', '^',
134        '+','-', '*', '/', '%',
135        ',', ';', '?', '.', ':'
136        ),
137    'CASE_SENSITIVE' => array(
138        GESHI_COMMENTS => false,
139        1 => true,
140        2 => true,
141        3 => true,
142        ),
143    'STYLES' => array(
144        'KEYWORDS' => array(
145            1 => 'color: #b1b100;',
146            2 => 'color: #000000; font-weight: bold;',
147            3 => 'color: #000066;'
148            ),
149        'COMMENTS' => array(
150            1 => 'color: #666666; font-style: italic;',
151            2 => 'color: #009966; font-style: italic;',
152            3 => 'color: #0000ff;',
153            4 => 'color: #cc0000; font-style: italic;',
154            5 => 'color: #0000ff;',
155            'MULTI' => 'color: #666666; font-style: italic;'
156            ),
157        'ESCAPE_CHAR' => array(
158            0 => 'color: #000099; font-weight: bold;',
159            'HARD' => 'color: #000099; font-weight: bold;'
160            ),
161        'BRACKETS' => array(
162            0 => 'color: #009900;'
163            ),
164        'STRINGS' => array(
165            0 => 'color: #ff0000;',
166            'HARD' => 'color: #ff0000;'
167            ),
168        'NUMBERS' => array(
169            0 => 'color: #cc66cc;'
170            ),
171        'METHODS' => array(
172            1 => 'color: #006600;',
173            2 => 'color: #006600;'
174            ),
175        'SYMBOLS' => array(
176            0 => 'color: #339933;'
177            ),
178        'REGEXPS' => array(
179            0 => 'color: #0000ff;',
180            4 => 'color: #009999;',
181            ),
182        'SCRIPT' => array(
183            )
184        ),
185    'URLS' => array(
186        1 => '',
187        2 => '',
188        3 => 'http://perldoc.perl.org/functions/{FNAMEL}.html'
189        ),
190    'OOLANG' => true,
191    'OBJECT_SPLITTERS' => array(
192        1 => '-&gt;',
193        2 => '::'
194        ),
195    'REGEXPS' => array(
196        //Variable
197        0 => '(?:\$[\$#]?|\\\\(?:[@%*]?|\\\\*\$|&amp;)|%[$]?|@[$]?|\*[$]?|&amp;[$]?)[a-zA-Z_][a-zA-Z0-9_]*',
198        //File Descriptor
199        4 => '&lt;[a-zA-Z_][a-zA-Z0-9_]*&gt;',
200        ),
201    'STRICT_MODE_APPLIES' => GESHI_NEVER,
202    'SCRIPT_DELIMITERS' => array(
203        ),
204    'HIGHLIGHT_STRICT_BLOCK' => array(
205        ),
206    'PARSER_CONTROL' => array(
207        'COMMENTS' => array(
208            'DISALLOWED_BEFORE' => '$'
209        )
210    )
211);
212