| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Perl::Lint::Keywords; | 
| 2 | 133 |  |  | 133 |  | 1183 | use strict; | 
|  | 133 |  |  |  |  | 152 |  | 
|  | 133 |  |  |  |  | 2862 |  | 
| 3 | 133 |  |  | 133 |  | 379 | use warnings; | 
|  | 133 |  |  |  |  | 1450 |  | 
|  | 133 |  |  |  |  | 3728 |  | 
| 4 | 133 |  |  | 133 |  | 2270 | use B::Keywords; | 
|  | 133 |  |  |  |  | 4124 |  | 
|  | 133 |  |  |  |  | 4056 |  | 
| 5 | 133 |  |  | 133 |  | 431 | use parent qw/Exporter/; | 
|  | 133 |  |  |  |  | 1420 |  | 
|  | 133 |  |  |  |  | 519 |  | 
| 6 |  |  |  |  |  |  | our @EXPORT = qw/ | 
| 7 |  |  |  |  |  |  | is_perl_builtin | 
| 8 |  |  |  |  |  |  | is_perl_builtin_which_provide_list_context | 
| 9 |  |  |  |  |  |  | is_perl_builtin_which_take_multiple_arguments | 
| 10 |  |  |  |  |  |  | is_perl_bareword | 
| 11 |  |  |  |  |  |  | is_perl_pragma | 
| 12 |  |  |  |  |  |  | /; | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | my %builtin_func_map; | 
| 15 |  |  |  |  |  |  | for my $func (@B::Keywords::Functions) { | 
| 16 |  |  |  |  |  |  | $builtin_func_map{$func} = 1; | 
| 17 |  |  |  |  |  |  | } | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | my %bareword_map; | 
| 20 |  |  |  |  |  |  | for my $bareword (@B::Keywords::Barewords) { | 
| 21 |  |  |  |  |  |  | $bareword_map{$bareword} = 1; | 
| 22 |  |  |  |  |  |  | } | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  | # perldoc -uT perlfunc | grep '=item.*LIST' | sed 's/(//' | awk '{print $2 " => 1,"}' | uniq | 
| 25 |  |  |  |  |  |  | my %builtin_func_which_provide_list_context_map = ( | 
| 26 |  |  |  |  |  |  | chmod    => 1, | 
| 27 |  |  |  |  |  |  | chomp    => 1, | 
| 28 |  |  |  |  |  |  | chop     => 1, | 
| 29 |  |  |  |  |  |  | chown    => 1, | 
| 30 |  |  |  |  |  |  | die      => 1, | 
| 31 |  |  |  |  |  |  | do       => 1, | 
| 32 |  |  |  |  |  |  | exec     => 1, | 
| 33 |  |  |  |  |  |  | formline => 1, | 
| 34 |  |  |  |  |  |  | grep     => 1, | 
| 35 |  |  |  |  |  |  | import   => 1, | 
| 36 |  |  |  |  |  |  | join     => 1, | 
| 37 |  |  |  |  |  |  | kill     => 1, | 
| 38 |  |  |  |  |  |  | map      => 1, | 
| 39 |  |  |  |  |  |  | no       => 1, | 
| 40 |  |  |  |  |  |  | open     => 1, | 
| 41 |  |  |  |  |  |  | pack     => 1, | 
| 42 |  |  |  |  |  |  | print    => 1, | 
| 43 |  |  |  |  |  |  | printf   => 1, | 
| 44 |  |  |  |  |  |  | push     => 1, | 
| 45 |  |  |  |  |  |  | reverse  => 1, | 
| 46 |  |  |  |  |  |  | say      => 1, | 
| 47 |  |  |  |  |  |  | sort     => 1, | 
| 48 |  |  |  |  |  |  | splice   => 1, | 
| 49 |  |  |  |  |  |  | sprintf  => 1, | 
| 50 |  |  |  |  |  |  | syscall  => 1, | 
| 51 |  |  |  |  |  |  | system   => 1, | 
| 52 |  |  |  |  |  |  | tie      => 1, | 
| 53 |  |  |  |  |  |  | unlink   => 1, | 
| 54 |  |  |  |  |  |  | unshift  => 1, | 
| 55 |  |  |  |  |  |  | use      => 1, | 
| 56 |  |  |  |  |  |  | utime    => 1, | 
| 57 |  |  |  |  |  |  | warn     => 1, | 
| 58 |  |  |  |  |  |  | ); | 
| 59 |  |  |  |  |  |  |  | 
| 60 |  |  |  |  |  |  | # perldoc -uT perlfunc | grep '=item.*[A-Z],' | awk '{print $2 " => 1,"}' | uniq | 
| 61 |  |  |  |  |  |  | my %builtin_func_which_take_multiple_arguments_map = ( | 
| 62 |  |  |  |  |  |  | accept        => 1, | 
| 63 |  |  |  |  |  |  | atan2         => 1, | 
| 64 |  |  |  |  |  |  | bind          => 1, | 
| 65 |  |  |  |  |  |  | binmode       => 1, | 
| 66 |  |  |  |  |  |  | bless         => 1, | 
| 67 |  |  |  |  |  |  | connect       => 1, | 
| 68 |  |  |  |  |  |  | crypt         => 1, | 
| 69 |  |  |  |  |  |  | dbmopen       => 1, | 
| 70 |  |  |  |  |  |  | fcntl         => 1, | 
| 71 |  |  |  |  |  |  | flock         => 1, | 
| 72 |  |  |  |  |  |  | formline      => 1, | 
| 73 |  |  |  |  |  |  | getpriority   => 1, | 
| 74 |  |  |  |  |  |  | getservbyname => 1, | 
| 75 |  |  |  |  |  |  | gethostbyaddr => 1, | 
| 76 |  |  |  |  |  |  | getnetbyaddr  => 1, | 
| 77 |  |  |  |  |  |  | getservbyport => 1, | 
| 78 |  |  |  |  |  |  | getsockopt    => 1, | 
| 79 |  |  |  |  |  |  | grep          => 1, | 
| 80 |  |  |  |  |  |  | index         => 1, | 
| 81 |  |  |  |  |  |  | ioctl         => 1, | 
| 82 |  |  |  |  |  |  | join          => 1, | 
| 83 |  |  |  |  |  |  | kill          => 1, | 
| 84 |  |  |  |  |  |  | link          => 1, | 
| 85 |  |  |  |  |  |  | listen        => 1, | 
| 86 |  |  |  |  |  |  | map           => 1, | 
| 87 |  |  |  |  |  |  | mkdir         => 1, | 
| 88 |  |  |  |  |  |  | msgctl        => 1, | 
| 89 |  |  |  |  |  |  | msgget        => 1, | 
| 90 |  |  |  |  |  |  | msgrcv        => 1, | 
| 91 |  |  |  |  |  |  | msgsnd        => 1, | 
| 92 |  |  |  |  |  |  | open          => 1, | 
| 93 |  |  |  |  |  |  | opendir       => 1, | 
| 94 |  |  |  |  |  |  | pack          => 1, | 
| 95 |  |  |  |  |  |  | pipe          => 1, | 
| 96 |  |  |  |  |  |  | printf        => 1, | 
| 97 |  |  |  |  |  |  | push          => 1, | 
| 98 |  |  |  |  |  |  | read          => 1, | 
| 99 |  |  |  |  |  |  | recv          => 1, | 
| 100 |  |  |  |  |  |  | rename        => 1, | 
| 101 |  |  |  |  |  |  | rindex        => 1, | 
| 102 |  |  |  |  |  |  | seek          => 1, | 
| 103 |  |  |  |  |  |  | seekdir       => 1, | 
| 104 |  |  |  |  |  |  | select        => 1, | 
| 105 |  |  |  |  |  |  | semctl        => 1, | 
| 106 |  |  |  |  |  |  | semget        => 1, | 
| 107 |  |  |  |  |  |  | semop         => 1, | 
| 108 |  |  |  |  |  |  | send          => 1, | 
| 109 |  |  |  |  |  |  | setpgrp       => 1, | 
| 110 |  |  |  |  |  |  | setpriority   => 1, | 
| 111 |  |  |  |  |  |  | setsockopt    => 1, | 
| 112 |  |  |  |  |  |  | shmctl        => 1, | 
| 113 |  |  |  |  |  |  | shmget        => 1, | 
| 114 |  |  |  |  |  |  | shmread       => 1, | 
| 115 |  |  |  |  |  |  | shmwrite      => 1, | 
| 116 |  |  |  |  |  |  | shutdown      => 1, | 
| 117 |  |  |  |  |  |  | socket        => 1, | 
| 118 |  |  |  |  |  |  | socketpair    => 1, | 
| 119 |  |  |  |  |  |  | splice        => 1, | 
| 120 |  |  |  |  |  |  | split         => 1, | 
| 121 |  |  |  |  |  |  | sprintf       => 1, | 
| 122 |  |  |  |  |  |  | substr        => 1, | 
| 123 |  |  |  |  |  |  | symlink       => 1, | 
| 124 |  |  |  |  |  |  | syscall       => 1, | 
| 125 |  |  |  |  |  |  | sysopen       => 1, | 
| 126 |  |  |  |  |  |  | sysread       => 1, | 
| 127 |  |  |  |  |  |  | sysseek       => 1, | 
| 128 |  |  |  |  |  |  | syswrite      => 1, | 
| 129 |  |  |  |  |  |  | tie           => 1, | 
| 130 |  |  |  |  |  |  | truncate      => 1, | 
| 131 |  |  |  |  |  |  | unpack        => 1, | 
| 132 |  |  |  |  |  |  | unshift       => 1, | 
| 133 |  |  |  |  |  |  | vec           => 1, | 
| 134 |  |  |  |  |  |  | waitpid       => 1, | 
| 135 |  |  |  |  |  |  | %builtin_func_which_provide_list_context_map, | 
| 136 |  |  |  |  |  |  | ); | 
| 137 |  |  |  |  |  |  |  | 
| 138 |  |  |  |  |  |  | # from `Module::CoreList->find_modules(qr/^[a-z].*/);` | 
| 139 |  |  |  |  |  |  | # NOTE the above script is a bit slow, so results of this are hardcoded | 
| 140 |  |  |  |  |  |  | my %pragma_map = ( | 
| 141 |  |  |  |  |  |  | 'arybase'                    => 1, | 
| 142 |  |  |  |  |  |  | 'assertions'                 => 1, | 
| 143 |  |  |  |  |  |  | 'assertions::activate'       => 1, | 
| 144 |  |  |  |  |  |  | 'assertions::compat'         => 1, | 
| 145 |  |  |  |  |  |  | 'attributes'                 => 1, | 
| 146 |  |  |  |  |  |  | 'attrs'                      => 1, | 
| 147 |  |  |  |  |  |  | 'autodie'                    => 1, | 
| 148 |  |  |  |  |  |  | 'autodie::exception'         => 1, | 
| 149 |  |  |  |  |  |  | 'autodie::exception::system' => 1, | 
| 150 |  |  |  |  |  |  | 'autodie::hints'             => 1, | 
| 151 |  |  |  |  |  |  | 'autodie::skip'              => 1, | 
| 152 |  |  |  |  |  |  | 'autouse'                    => 1, | 
| 153 |  |  |  |  |  |  | 'base'                       => 1, | 
| 154 |  |  |  |  |  |  | 'bigint'                     => 1, | 
| 155 |  |  |  |  |  |  | 'bignum'                     => 1, | 
| 156 |  |  |  |  |  |  | 'bigrat'                     => 1, | 
| 157 |  |  |  |  |  |  | 'blib'                       => 1, | 
| 158 |  |  |  |  |  |  | 'bytes'                      => 1, | 
| 159 |  |  |  |  |  |  | 'charnames'                  => 1, | 
| 160 |  |  |  |  |  |  | 'constant'                   => 1, | 
| 161 |  |  |  |  |  |  | 'deprecate'                  => 1, | 
| 162 |  |  |  |  |  |  | 'diagnostics'                => 1, | 
| 163 |  |  |  |  |  |  | 'encoding'                   => 1, | 
| 164 |  |  |  |  |  |  | 'encoding::warnings'         => 1, | 
| 165 |  |  |  |  |  |  | 'feature'                    => 1, | 
| 166 |  |  |  |  |  |  | 'fields'                     => 1, | 
| 167 |  |  |  |  |  |  | 'filetest'                   => 1, | 
| 168 |  |  |  |  |  |  | 'if'                         => 1, | 
| 169 |  |  |  |  |  |  | 'inc::latest'                => 1, | 
| 170 |  |  |  |  |  |  | 'integer'                    => 1, | 
| 171 |  |  |  |  |  |  | 'legacy'                     => 1, | 
| 172 |  |  |  |  |  |  | 'less'                       => 1, | 
| 173 |  |  |  |  |  |  | 'lib'                        => 1, | 
| 174 |  |  |  |  |  |  | 'locale'                     => 1, | 
| 175 |  |  |  |  |  |  | 'mro'                        => 1, | 
| 176 |  |  |  |  |  |  | 'open'                       => 1, | 
| 177 |  |  |  |  |  |  | 'ops'                        => 1, | 
| 178 |  |  |  |  |  |  | 'overload'                   => 1, | 
| 179 |  |  |  |  |  |  | 'overload::numbers'          => 1, | 
| 180 |  |  |  |  |  |  | 'overloading'                => 1, | 
| 181 |  |  |  |  |  |  | 'parent'                     => 1, | 
| 182 |  |  |  |  |  |  | 'perlfaq'                    => 1, | 
| 183 |  |  |  |  |  |  | 're'                         => 1, | 
| 184 |  |  |  |  |  |  | 'sigtrap'                    => 1, | 
| 185 |  |  |  |  |  |  | 'sort'                       => 1, | 
| 186 |  |  |  |  |  |  | 'strict'                     => 1, | 
| 187 |  |  |  |  |  |  | 'subs'                       => 1, | 
| 188 |  |  |  |  |  |  | 'threads'                    => 1, | 
| 189 |  |  |  |  |  |  | 'threads::shared'            => 1, | 
| 190 |  |  |  |  |  |  | 'unicore::Name'              => 1, | 
| 191 |  |  |  |  |  |  | 'utf8'                       => 1, | 
| 192 |  |  |  |  |  |  | 'vars'                       => 1, | 
| 193 |  |  |  |  |  |  | 'version'                    => 1, | 
| 194 |  |  |  |  |  |  | 'vmsish'                     => 1, | 
| 195 |  |  |  |  |  |  | 'warnings'                   => 1, | 
| 196 |  |  |  |  |  |  | 'warnings::register'         => 1, | 
| 197 |  |  |  |  |  |  | ); | 
| 198 |  |  |  |  |  |  |  | 
| 199 |  |  |  |  |  |  | sub is_perl_builtin { | 
| 200 | 17 |  |  | 17 | 0 | 13 | my $key = shift; | 
| 201 | 17 | 50 |  |  |  | 18 | return if !$key; | 
| 202 |  |  |  |  |  |  |  | 
| 203 | 17 |  |  |  |  | 49 | return exists $builtin_func_map{$key}; | 
| 204 |  |  |  |  |  |  | } | 
| 205 |  |  |  |  |  |  |  | 
| 206 |  |  |  |  |  |  | sub is_perl_builtin_which_provide_list_context { | 
| 207 | 0 |  |  | 0 | 0 | 0 | my $key = shift; | 
| 208 | 0 | 0 |  |  |  | 0 | return if !$key; | 
| 209 |  |  |  |  |  |  |  | 
| 210 | 0 |  |  |  |  | 0 | return exists $builtin_func_which_provide_list_context_map{$key}; | 
| 211 |  |  |  |  |  |  | } | 
| 212 |  |  |  |  |  |  |  | 
| 213 |  |  |  |  |  |  | sub is_perl_builtin_which_take_multiple_arguments { | 
| 214 | 17 |  |  | 17 | 0 | 19 | my $key = shift; | 
| 215 | 17 | 50 |  |  |  | 29 | return if !$key; | 
| 216 |  |  |  |  |  |  |  | 
| 217 | 17 |  |  |  |  | 66 | return exists $builtin_func_which_take_multiple_arguments_map{$key}; | 
| 218 |  |  |  |  |  |  | } | 
| 219 |  |  |  |  |  |  |  | 
| 220 |  |  |  |  |  |  | sub is_perl_bareword { | 
| 221 | 11 |  |  | 11 | 0 | 10 | my $key = shift; | 
| 222 | 11 | 50 |  |  |  | 13 | return if !$key; | 
| 223 |  |  |  |  |  |  |  | 
| 224 | 11 |  |  |  |  | 22 | return exists $bareword_map{$key}; | 
| 225 |  |  |  |  |  |  | } | 
| 226 |  |  |  |  |  |  |  | 
| 227 |  |  |  |  |  |  | sub is_perl_pragma { | 
| 228 | 21 |  |  | 21 | 0 | 23 | my $key = shift; | 
| 229 | 21 | 50 |  |  |  | 36 | return if !$key; | 
| 230 |  |  |  |  |  |  |  | 
| 231 | 21 |  |  |  |  | 115 | return exists $pragma_map{$key}; | 
| 232 |  |  |  |  |  |  | } | 
| 233 |  |  |  |  |  |  |  | 
| 234 |  |  |  |  |  |  | 1; | 
| 235 |  |  |  |  |  |  |  |