File: mkExt

package info (click to toggle)
perl-tk 1:804.033-2
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 34,724 kB
  • ctags: 37,174
  • sloc: ansic: 349,541; perl: 52,192; sh: 17,904; makefile: 5,732; asm: 3,565; ada: 1,681; pascal: 1,089; cpp: 1,006; yacc: 883; cs: 879
file content (38 lines) | stat: -rwxr-xr-x 741 bytes parent folder | download | duplicates (12)
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);
 }