File: dh-exec-illiterate-tangle

package info (click to toggle)
dh-exec 0.31
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 324 kB
  • sloc: ansic: 530; perl: 178; makefile: 126; sh: 67
file content (43 lines) | stat: -rwxr-xr-x 1,169 bytes parent folder | download | duplicates (10)
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
39
40
41
42
43
#! /usr/bin/perl -w
use strict;

# The first line is the she-bang, always ignore it.
<>;

my @files;
my $last_file;

while (<>) {
        next unless /[\`']/;

        # Find `...' constructs. The first is always the source, the
        # second is the destination.
        while (/\`([^']+)'/) {
                if ($last_file) {
                        push (@files, {src => $last_file, dst => $1});
                        $last_file = undef;
                } else {
                        $last_file = $1;
                }
                s/\`([^']+)'//;
        }

        # Once done, find the '...' constructs, which is always a
        # directory, no second stuff.
        while (/'([^' ]+)'/) {
                push (@files, {src => $1, solo => 1});
                s/'([^' ]+)'//;
        }
};

# Great, we got the stuff extracted, now turn it into something
# illiterate.
foreach (@files) {
        if (defined ($_->{solo})) {
                print $_->{src} . "\n";
        } elsif ($_->{dst} =~ /\/$/) {
                print $_->{src} . " " . $_->{dst} . "\n";
        } else {
                print $_->{src} . " => " . $_->{dst} . "\n";
        }
}