Acme-Pythonic
view release on metacpan or search on metacpan
lib/Acme/Pythonic.pm view on Meta::CPAN
# easily about the end of the code in this line. It is later
# appended back in the continue block below.
$comment = $line =~ s/(\s*$tc)//o ? $1 : '';
next if $line =~ /^\s*$/;
if (!$joining) {
$unbalanced_paren = left_parenthesize($line);
$might_be_modifier = $line =~ /^\s*(?:if|unless|while|until|for|foreach)\b/;
$line_with_modifier = \$line if $might_be_modifier;
($indent) = $line =~ /^(\s*)/;
$indent = length(expand($indent));
}
if ($line =~ /(?:,|=>)\s*$/ || $line =~ s/\\\s*$//) {
++$joining;
next if $joining > 1; # if 1 we need yet to handle indentation
} else {
$joining = 0;
}
# Handle trailing colons, which can be Pythonic, mark a labeled
# block, mean some map, or &-sub call, etc.
#
# We check the parity of the number of ending colons to try to
# avoid breaking things like
#
# print for keys %main::
#
my $bracket_opened_by = '';
if ($line =~ /(:+)$/ && length($1) % 2) {
$might_be_modifier = 0;
# We perform some checks because labels have to keep their colon.
if ($line !~ /^\s*$id:$/o ||
$line =~ /[[:lower:]]/ || # labels are not allowed to have lower-case letters
$line =~ /^\s*(?:BEGIN|CHECK|INIT|END):$/) {
chop $line;
if ($unbalanced_paren) {
$line .= ")";
$unbalanced_paren = 0;
} else {
t/text_wrap.t view on Meta::CPAN
use Text::Tabs qw(expand unexpand)
sub wrap:
my ($ip, $xp, @t) = @_
local($Text::Tabs::tabstop) = $tabstop
my $r = ""
my $tail = pop(@t)
my $t = expand(join("", (map { /\s+\z/ ? ( $_ ) : ($_, ' ') } @t), $tail))
my $lead = $ip
my $ll = $columns - length(expand($ip)) - 1
$ll = 0 if $ll < 0
my $nll = $columns - length(expand($xp)) - 1
my $nl = ""
my $remainder = ""
use re 'taint'
pos($t) = 0
while $t !~ /\G\s*\Z/gc:
if $t =~ /\G([^\n]{0,$ll})($break|\z)/xmgc:
$r .= $unexpand \
? unexpand($nl . $lead . $1) \
t/text_wrap.t view on Meta::CPAN
$lead = $xp
$ll = $nll
$nl = $separator
$r .= $remainder
print "-----------$r---------\n" if $debug
print "Finish up with '$lead'\n" if $debug
$r .= $lead . substr($t, pos($t), length($t)-pos($t)) \
if pos($t) ne length($t)
print "-----------$r---------\n" if $debug
return $r
sub fill:
my ($ip, $xp, @raw) = @_
my @para
my $pp
( run in 0.534 second using v1.01-cache-2.11-cpan-65fba6d93b7 )