12 $newname =~ s/\.pl$/.pm/ || next;
13 $newname =~ s#(.*/)?(\w+)#$1\u$2#;
15 warn "Won't overwrite existing $newname\n";
21 print "$oldpack => $newpack\n" if $verbose;
23 s/(sub\s+)(\w+)(\s*\{[ \t]*\n)\s*package\s+$oldpack\s*;[ \t]*\n+/${1}main'$2$3/ig;
25 @export = m/sub\s+main'(\w+)/g;
26 s/(sub\s+)main'(\w+)/$1$2/g;
29 @export = m/sub\s+([A-Za-z]\w*)/g;
31 @export_ok = grep($keyword{$_}, @export);
32 @export = grep(!$keyword{$_}, @export);
33 @export{@export} = (1) x @export;
35 s/(#.*)require ['"]$oldpack\.pl['"]/$1use $newpack/;
36 s/(package\s*)($oldpack)\s*;[ \t]*\n+//ig;
37 s/([\$\@%&*])'(\w+)/&xlate($1,"",$2)/eg;
38 s/([\$\@%&*]?)(\w+)'(\w+)/&xlate($1,$2,$3)/eg;
39 if (!/\$\[\s*\)?\s*=\s*[^0\s]/) {
40 s/^\s*(local\s*\()?\s*\$\[\s*\)?\s*=\s*0\s*;[ \t]*\n//g;
45 s/open\s+(\w+)/open($1)/g;
47 if (s/\bdie\b/croak/g) {
48 $carp = "use Carp;\n";
49 s/croak "([^"]*)\\n"/croak "$1"/g;
55 $export_ok = "\@EXPORT_OK = qw(@export_ok);\n";
61 open(PM, ">$newname") || warn "Can't create $newname: $!\n";
68 \@EXPORT = qw(@export);
75 local($prefix, $pack, $ident) = @_;
76 if ($prefix eq '' && $ident =~ /^(t|s|m|d|ing|ll|ed|ve|re)$/) {
79 elsif ($pack eq "" || $pack eq "main") {
80 if ($export{$ident}) {
84 "$prefix${pack}::$ident";
87 elsif ($pack eq $oldpack) {
88 "$prefix${newpack}::$ident";
91 "$prefix${pack}::$ident";