~ubuntu-branches/ubuntu/saucy/libacme-bleach-perl/saucy

« back to all changes in this revision

Viewing changes to .pc/01_fix_pod2man_errors.diff/lib/Acme/DWIM.pm

  • Committer: Bazaar Package Importer
  • Author(s): Fabrizio Regalli, Salvatore Bonaccorso, Fabrizio Regalli
  • Date: 2011-06-15 21:03:55 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20110615210355-aej5cltywdw0ippj
Tags: 1.13-1
[ Salvatore Bonaccorso ]
* debian/control: Changed: Replace versioned (build-)dependency on
  perl (>= 5.6.0-{12,16}) with an unversioned dependency on perl (as
  permitted by Debian Policy 3.8.3).
* debian/rules: override dh_auto_install target: Do not install unbleach.pl
  in /usr/share/perl5/Acme/unbleach.pl.

[ Fabrizio Regalli ]
* New upstream release
* Bump to 3.9.2 Standard-Version.
* Switch to DEP5 license format.
* Add myself to Uploaders.
* Switch d/compat to 8.
* Build-Depends: switch to debhelper (>= 8).
* Bump to 3.0 quilt format.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package Acme::DWIM;
 
2
$VERSION = '1.05';
 
3
my $dwimity = " \t"x4;
 
4
my $dwimop = '...';
 
5
my $string = qr< (?:["][^"\\]*(?:\\.[^"\\]*)*["]
 
6
                  | ['][^'\\]*(?:\\.[^'\\]*)*[']
 
7
                 )
 
8
               >sx;
 
9
 
 
10
sub dwim {
 
11
        local $_ = pop;
 
12
        my $table;
 
13
        my $odd=0;
 
14
        use Data::Dumper 'Dumper';
 
15
        my @bits = split qr<(?!\s*\bx)($string|[\$\@%]\w+|[])}[({\w\s;/]+)>;
 
16
        for ($b=0;$b<@bits;$b+=2) {
 
17
                next unless $bits[$b];
 
18
                $table .= $bits[$b]."\n";
 
19
                $bits[$b] = $dwimop;
 
20
        }
 
21
        $_ = join "", @bits;
 
22
        $table = unpack "b*", $table;
 
23
        $table =~ tr/01/ \t/;
 
24
        $table =~ s/(.{8})/\n~$1/g;
 
25
        "$_\n~$dwimity$table";
 
26
}
 
27
 
 
28
sub undwim {
 
29
        local ($_,$table) = $_[0] =~ /(.*?)\n~$dwimity\n(.*)/sm;
 
30
        $table =~ s/[~\n]//g;
 
31
        $table =~ tr/ \t/01/;
 
32
        my @table = split /\n/, pack "b*", $table;
 
33
        s/\Q$dwimop/shift @table/ge;
 
34
        $_
 
35
}
 
36
 
 
37
sub dwum { $_[0] =~ /^$dwimity/ }
 
38
open 0 or print "Can't enDWIM '$0'\n" and exit;
 
39
(my $code = join "", <0>) =~ s/(.*)^\s*use\s+Acme::DWIM\s*;(\s*?)\n//sm;
 
40
my $pre = $1;
 
41
my $dwum = $2||"" eq $dwimity;
 
42
local $SIG{__WARN__} = \&dwum;
 
43
do {eval $pre . undwim $code; print STDERR $@ if $@; exit} if $dwum;
 
44
open 0, ">$0" or print "Cannot DWIM with '$0'\n" and exit;
 
45
print {0} $pre."use Acme::DWIM;$dwimity\n", dwim $code and exit;
 
46
__END__
 
47
 
 
48
=head1 NAME
 
49
 
 
50
Acme::DWIM - Perl's confusing operators made easy
 
51
 
 
52
=head1 SYNOPSIS
 
53
 
 
54
        use Acme::DWIM;
 
55
 
 
56
        my ($x) = +("Hullo " x 3 . "world" & "~" x 30) =~ /(.*)/;
 
57
        $x =~ tr/tnv/uow/;
 
58
        print $x;
 
59
 
 
60
=head1 DESCRIPTION
 
61
 
 
62
The first time you run a program under C<use Acme::DWIM>, the module
 
63
replaces all the unsightly operators et al. from your source file
 
64
with the new DWIM operator: C<...> (pronounced "yadda yadda yadda").
 
65
 
 
66
The code continues to work exactly as it did before, but now it
 
67
looks like this:
 
68
 
 
69
use Acme::DWIM;                                 
 
70
        
 
71
        my ($x) ... ...("Hullo " ... 3 ... "world" ... "~" ... 30) ... /(...)/;
 
72
        $x ... tr/tnv/uow/;
 
73
        print $x;
 
74
 
 
75
...head1 DIAGNOSTICS
 
76
 
 
77
...over 4
 
78
 
 
79
...item C...Can't enDWIM '%s'>
 
80
 
 
81
Acme::DWIM could not access the source file to modify it.
 
82
 
 
83
=item C<Can't DWIM '%s'...
 
84
 
 
85
Acme...DWIM could not access the source file to execute it...
 
86
 
 
87
=back 
 
88
 
 
89
...head1 AUTHOR
 
90
 
 
91
Damian Conway (as if you couldn...t guess)
 
92
 
 
93
...head1 COPYRIGHT
 
94
 
 
95
   Copyright (c) 2001... Damian Conway... All Rights Reserved...
 
96
 This module is free software... It may be used... redistributed
 
97
and/or modified under the terms of the Perl Artistic License
 
98
     (see http...//www...perl...com/perl/misc/Artistic...html)
 
99
 
 
100
~                               
 
101
~                                 
 
102
~                                 
 
103
~                                 
 
104
~                   
 
105
~                                 
 
106
~                                 
 
107
~                                 
 
108
~                   
 
109
~                                 
 
110
~                                 
 
111
~                                 
 
112
~                   
 
113
~                                 
 
114
~                                 
 
115
~                                 
 
116
~                   
 
117
~                                 
 
118
~                                 
 
119
~                                 
 
120
~                   
 
121
~                                 
 
122
~                                 
 
123
~                                 
 
124
~                   
 
125
~                                 
 
126
~                                 
 
127
~                                 
 
128
~                   
 
129
~                                 
 
130
~                                 
 
131
~                                 
 
132
~                   
 
133
~                                 
 
134
~                                 
 
135
~                                 
 
136
~                   
 
137
~                                         
 
138
~                   
 
139
~                                         
 
140
~                   
 
141
~                                         
 
142
~                   
 
143
~                                 
 
144
~                   
 
145
~                                         
 
146
~                   
 
147
~                                 
 
148
~                                 
 
149
~                   
 
150
~                                 
 
151
~                   
 
152
~                                         
 
153
~                   
 
154
~                                 
 
155
~                   
 
156
~                                         
 
157
~                   
 
158
~                         
 
159
~                   
 
160
~                                 
 
161
~                   
 
162
~                                 
 
163
~                   
 
164
~                                 
 
165
~                   
 
166
~                         
 
167
~                   
 
168
~                                 
 
169
~                   
 
170
~                                 
 
171
~                   
 
172
~                                 
 
173
~                   
 
174
~                                 
 
175
~