Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

364 lines
4.5 KiB

  1. @rem = '--*-Perl-*--
  2. @echo off
  3. if "%OS%" == "Windows_NT" goto WinNT
  4. perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
  5. goto endofperl
  6. :WinNT
  7. perl -x -S "%0" %*
  8. if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl
  9. if %errorlevel% == 9009 echo You do not have Perl in your PATH.
  10. goto endofperl
  11. @rem ';
  12. #!perl
  13. #line 14
  14. eval 'exec P:\Apps\ActivePerl\temp\bin\MSWin32-x86-object\perl.exe -S $0 ${1+"$@"}'
  15. if $running_under_some_shell;
  16. =head1 NAME
  17. pl2pm - Rough tool to translate Perl4 .pl files to Perl5 .pm modules.
  18. =head1 SYNOPSIS
  19. B<pl2pm> F<files>
  20. =head1 DESCRIPTION
  21. B<pl2pm> is a tool to aid in the conversion of Perl4-style .pl
  22. library files to Perl5-style library modules. Usually, your old .pl
  23. file will still work fine and you should only use this tool if you
  24. plan to update your library to use some of the newer Perl 5 features,
  25. such as AutoLoading.
  26. =head1 LIMITATIONS
  27. It's just a first step, but it's usually a good first step.
  28. =head1 AUTHOR
  29. Larry Wall <[email protected]>
  30. =cut
  31. while (<DATA>) {
  32. chop;
  33. $keyword{$_} = 1;
  34. }
  35. undef $/;
  36. $* = 1;
  37. while (<>) {
  38. $newname = $ARGV;
  39. $newname =~ s/\.pl$/.pm/ || next;
  40. $newname =~ s#(.*/)?(\w+)#$1\u$2#;
  41. if (-f $newname) {
  42. warn "Won't overwrite existing $newname\n";
  43. next;
  44. }
  45. $oldpack = $2;
  46. $newpack = "\u$2";
  47. @export = ();
  48. print "$oldpack => $newpack\n" if $verbose;
  49. s/\bstd(in|out|err)\b/\U$&/g;
  50. s/(sub\s+)(\w+)(\s*\{[ \t]*\n)\s*package\s+$oldpack\s*;[ \t]*\n+/${1}main'$2$3/ig;
  51. if (/sub\s+main'/) {
  52. @export = m/sub\s+main'(\w+)/g;
  53. s/(sub\s+)main'(\w+)/$1$2/g;
  54. }
  55. else {
  56. @export = m/sub\s+([A-Za-z]\w*)/g;
  57. }
  58. @export_ok = grep($keyword{$_}, @export);
  59. @export = grep(!$keyword{$_}, @export);
  60. @export{@export} = (1) x @export;
  61. s/(^\s*);#/$1#/g;
  62. s/(#.*)require ['"]$oldpack\.pl['"]/$1use $newpack/;
  63. s/(package\s*)($oldpack)\s*;[ \t]*\n+//ig;
  64. s/([\$\@%&*])'(\w+)/&xlate($1,"",$2)/eg;
  65. s/([\$\@%&*]?)(\w+)'(\w+)/&xlate($1,$2,$3)/eg;
  66. if (!/\$\[\s*\)?\s*=\s*[^0\s]/) {
  67. s/^\s*(local\s*\()?\s*\$\[\s*\)?\s*=\s*0\s*;[ \t]*\n//g;
  68. s/\$\[\s*\+\s*//g;
  69. s/\s*\+\s*\$\[//g;
  70. s/\$\[/0/g;
  71. }
  72. s/open\s+(\w+)/open($1)/g;
  73. if (s/\bdie\b/croak/g) {
  74. $carp = "use Carp;\n";
  75. s/croak "([^"]*)\\n"/croak "$1"/g;
  76. }
  77. else {
  78. $carp = "";
  79. }
  80. if (@export_ok) {
  81. $export_ok = "\@EXPORT_OK = qw(@export_ok);\n";
  82. }
  83. else {
  84. $export_ok = "";
  85. }
  86. open(PM, ">$newname") || warn "Can't create $newname: $!\n";
  87. print PM <<"END";
  88. package $newpack;
  89. require 5.000;
  90. require Exporter;
  91. $carp
  92. \@ISA = qw(Exporter);
  93. \@EXPORT = qw(@export);
  94. $export_ok
  95. $_
  96. END
  97. }
  98. sub xlate {
  99. local($prefix, $pack, $ident) = @_;
  100. if ($prefix eq '' && $ident =~ /^(t|s|m|d|ing|ll|ed|ve|re)$/) {
  101. "${pack}'$ident";
  102. }
  103. elsif ($pack eq "" || $pack eq "main") {
  104. if ($export{$ident}) {
  105. "$prefix$ident";
  106. }
  107. else {
  108. "$prefix${pack}::$ident";
  109. }
  110. }
  111. elsif ($pack eq $oldpack) {
  112. "$prefix${newpack}::$ident";
  113. }
  114. else {
  115. "$prefix${pack}::$ident";
  116. }
  117. }
  118. __END__
  119. AUTOLOAD
  120. BEGIN
  121. CORE
  122. DESTROY
  123. END
  124. abs
  125. accept
  126. alarm
  127. and
  128. atan2
  129. bind
  130. binmode
  131. bless
  132. caller
  133. chdir
  134. chmod
  135. chop
  136. chown
  137. chr
  138. chroot
  139. close
  140. closedir
  141. cmp
  142. connect
  143. continue
  144. cos
  145. crypt
  146. dbmclose
  147. dbmopen
  148. defined
  149. delete
  150. die
  151. do
  152. dump
  153. each
  154. else
  155. elsif
  156. endgrent
  157. endhostent
  158. endnetent
  159. endprotoent
  160. endpwent
  161. endservent
  162. eof
  163. eq
  164. eval
  165. exec
  166. exit
  167. exp
  168. fcntl
  169. fileno
  170. flock
  171. for
  172. foreach
  173. fork
  174. format
  175. formline
  176. ge
  177. getc
  178. getgrent
  179. getgrgid
  180. getgrnam
  181. gethostbyaddr
  182. gethostbyname
  183. gethostent
  184. getlogin
  185. getnetbyaddr
  186. getnetbyname
  187. getnetent
  188. getpeername
  189. getpgrp
  190. getppid
  191. getpriority
  192. getprotobyname
  193. getprotobynumber
  194. getprotoent
  195. getpwent
  196. getpwnam
  197. getpwuid
  198. getservbyname
  199. getservbyport
  200. getservent
  201. getsockname
  202. getsockopt
  203. glob
  204. gmtime
  205. goto
  206. grep
  207. gt
  208. hex
  209. if
  210. index
  211. int
  212. ioctl
  213. join
  214. keys
  215. kill
  216. last
  217. lc
  218. lcfirst
  219. le
  220. length
  221. link
  222. listen
  223. local
  224. localtime
  225. log
  226. lstat
  227. lt
  228. m
  229. mkdir
  230. msgctl
  231. msgget
  232. msgrcv
  233. msgsnd
  234. my
  235. ne
  236. next
  237. no
  238. not
  239. oct
  240. open
  241. opendir
  242. or
  243. ord
  244. pack
  245. package
  246. pipe
  247. pop
  248. print
  249. printf
  250. push
  251. q
  252. qq
  253. quotemeta
  254. qw
  255. qx
  256. rand
  257. read
  258. readdir
  259. readline
  260. readlink
  261. readpipe
  262. recv
  263. redo
  264. ref
  265. rename
  266. require
  267. reset
  268. return
  269. reverse
  270. rewinddir
  271. rindex
  272. rmdir
  273. s
  274. scalar
  275. seek
  276. seekdir
  277. select
  278. semctl
  279. semget
  280. semop
  281. send
  282. setgrent
  283. sethostent
  284. setnetent
  285. setpgrp
  286. setpriority
  287. setprotoent
  288. setpwent
  289. setservent
  290. setsockopt
  291. shift
  292. shmctl
  293. shmget
  294. shmread
  295. shmwrite
  296. shutdown
  297. sin
  298. sleep
  299. socket
  300. socketpair
  301. sort
  302. splice
  303. split
  304. sprintf
  305. sqrt
  306. srand
  307. stat
  308. study
  309. sub
  310. substr
  311. symlink
  312. syscall
  313. sysread
  314. system
  315. syswrite
  316. tell
  317. telldir
  318. tie
  319. time
  320. times
  321. tr
  322. truncate
  323. uc
  324. ucfirst
  325. umask
  326. undef
  327. unless
  328. unlink
  329. unpack
  330. unshift
  331. untie
  332. until
  333. use
  334. utime
  335. values
  336. vec
  337. wait
  338. waitpid
  339. wantarray
  340. warn
  341. while
  342. write
  343. x
  344. xor
  345. y
  346. __END__
  347. :endofperl