root/floppyfw-3.0/perl/capsfix.pl

Revision 1, 1.2 KB (checked in by root, 6 years ago)

First post

Line 
1#!/usr/bin/perl
2#
3# $Id: capsfix.pl,v 1.3 2005/02/27 19:30:15 thomasez Exp $
4
5# This piece moves all CAPSed modules to it's own directory in case there are
6# modules with the same name with and without CAPS.
7#
8# It will not handle module paths with CAPS right now.
9# (I'm too lazy)
10#
11# Thomas Lundquist 2003-09-20
12
13# Using strict here is a good thing but microperl don't like it.
14# use strict;
15
16my $dir = "2.4-std";
17# my $dir = "test";
18
19my %files;
20my %paths;
21
22while (<>) {
23        if (/[A-Z]/ && !m/_CAPS\//) {
24                my (@mods) = split(/\t/);
25                foreach my $mod (@mods) {
26                        my ($path, $module);
27                        ($path, $module) = ($1, $2) 
28                                if ( $mod =~ /(.*)\/([A-Z|a-z|0-9|_|-]+\.o)/ );
29                        if ($module =~ /[A-Z]/) {
30                                if (/:/) {
31                                        $files{$module} = $path;
32                                        $paths{$path} = 1;
33                                }
34
35                                $mod =~ s/(.*)\/([A-Z|a-z|0-9|_|-]+\.o)/$1_CAPS\/$2/g;
36
37                        }
38                        $mod = "\t$mod" unless ($mod =~ /:/);   
39                        print $mod;
40                }
41        } else {
42                print;
43        }
44}
45
46#
47# Only need to make the new path once.
48#
49foreach my $p (keys (%paths)) {
50        my ($newpath) = $p . "_CAPS";
51        mkdir("$dir/$newpath",0755);
52}
53
54#
55# Copy files
56#
57foreach my $f (keys (%files)) {
58        my ($newpath) = $files{$f} . "_CAPS";
59        rename("$dir/$files{$f}/$f", "$dir/$newpath/$f");
60}
Note: See TracBrowser for help on using the browser.