Acme-Bleach
view release on metacpan or search on metacpan
lib/Acme/DWIM.pm view on Meta::CPAN
my $dwimop = '...';
my $string = qr< (?:["][^"\\]*(?:\\.[^"\\]*)*["]
| ['][^'\\]*(?:\\.[^'\\]*)*[']
)
>sx;
sub dwim {
local $_ = pop;
my $table;
my $odd=0;
use Data::Dumper 'Dumper';
my @bits = split qr<(?!\s*\bx)($string|[\$\@%]\w+|[])}[({\w\s;/]+)>;
for ($b=0;$b<@bits;$b+=2) {
next unless $bits[$b];
$table .= $bits[$b]."\n";
$bits[$b] = $dwimop;
}
$_ = join "", @bits;
$table = unpack "b*", $table;
$table =~ tr/01/ \t/;
$table =~ s/(.{8})/\n~$1/g;
( run in 0.263 second using v1.01-cache-2.11-cpan-4d50c553e7e )