File: mkExt

package info (click to toggle)
perl-tk 1%3A800.011-1
  • links: PTS
  • area: main
  • in suites: slink
  • size: 16,820 kB
  • ctags: 17,448
  • sloc: ansic: 189,575; perl: 31,426; makefile: 4,360; sh: 1,921; yacc: 762
file content (38 lines) | stat: -rwxr-xr-x 741 bytes parent folder | download | duplicates (15)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/local/bin/perl -w

sub translate
{
 my ($src,$dst,$ext,$ref) = @_;
 $ref = "\L$ref";
 my $Ref = "\u$ref";
 open(TEXT,"<$src") || die "Cannot open $src:$!";
 open(MINE,">$dst") || die "Cannot open $dst:$!";
 while (<TEXT>)
  {
   s/\b$Ref\b/$ext/g;
   s/${Ref}Cmd/${ext}Cmd/g;
   s/\b$ref\b/\L$ext/g;
   print MINE $_;
  }
 close(TEXT);
 close(MINE);
}

sub mkExt
{my ($ref,$ext) = @_;
 mkdir($ext,0777) unless (-d $ext);
 if (-f "Tk/$ext.pm")
  {
   rename("Tk/$ext.pm","$ext/$ext.pm");
  }
 translate("$ref/GNUmakefile","$ext/GNUmakefile",$ext,$ref);
 translate("$ref/Makefile.PL","$ext/Makefile.PL",$ext,$ref);
 translate("$ref/$ref.xs","$ext/$ext.xs",$ext,$ref);
}

my $ref = shift;

foreach $ext (@ARGV)
 {
  mkExt($ref,$ext);
 }