5
my $string = qr< (?:["][^"\\]*(?:\\.[^"\\]*)*["]
6
| ['][^'\\]*(?:\\.[^'\\]*)*[']
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";
22
$table = unpack "b*", $table;
24
$table =~ s/(.{8})/\n~$1/g;
25
"$_\n~$dwimity$table";
29
local ($_,$table) = $_[0] =~ /(.*?)\n~$dwimity\n(.*)/sm;
32
my @table = split /\n/, pack "b*", $table;
33
s/\Q$dwimop/shift @table/ge;
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;
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;
50
Acme::DWIM - Perl's confusing operators made easy
56
my ($x) = +("Hullo " x 3 . "world" & "~" x 30) =~ /(.*)/;
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").
66
The code continues to work exactly as it did before, but now it
71
my ($x) ... ...("Hullo " ... 3 ... "world" ... "~" ... 30) ... /(...)/;
79
...item C...Can't enDWIM '%s'>
81
Acme::DWIM could not access the source file to modify it.
83
=item C<Can't DWIM '%s'...
85
Acme...DWIM could not access the source file to execute it...
91
Damian Conway (as if you couldn...t guess)
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)