2013-07-18 20 views
0

我試圖讓perltidy格式化的if聲明是這樣的:perltidy格式多線

if ($self->image eq $_->[1] 
     and $self->extension eq $_->[2] 
     and $self->location eq $_->[3] 
     and $self->modified eq $_->[4] 
     and $self->accessed eq $_->[5]) { 

但無論我怎麼努力,它堅持格式化這樣的:

if ( $self->image eq $_->[1] 
    and $self->extension eq $_->[2] 
    and $self->location eq $_->[3] 
    and $self->modified eq $_->[4] 
    and $self->accessed eq $_->[5]) { 

另外,有沒有辦法得到這個塊的最後一行:

$dbh->do("INSERT INTO image VALUES(NULL, " 
    . $dbh->quote($self->image) . ", " 
    . $dbh->quote($self->extension) . ", " 
    . $dbh->quote($self->location) . "," 
    . $dbh->quote($self->modified) . "," 
    . $dbh->quote($self->accessed) 
    . ")"); 

to jum p到上一行像其他線路:

$dbh->do("INSERT INTO image VALUES(NULL, " 
    . $dbh->quote($self->image) . ", " 
    . $dbh->quote($self->extension) . ", " 
    . $dbh->quote($self->location) . "," 
    . $dbh->quote($self->modified) . "," 
    . $dbh->quote($self->accessed) . ")"); 

這是目前我在做什麼:

perltidy -ce -et=4 -l=100 -pt=2 -msc=1 -bar -ci=0 reporter.pm 

感謝。

回答

1

我對第一個問題沒有多少提供,但是第二個問題,你有沒有考慮重構它以使用佔位符?它可能會更好地格式化,自動爲您引用併爲您(和您的模塊的用戶)提供一個健康的屏障來防範SQL注入問題。

my $sth = $dbh->prepare('INSERT INTO image VALUES(NULL, ?, ?, ?, ?, ?)'); 
$sth->execute(
    $self->image, $self->extension, $self->location, 
    $self->modified, $self->accessed 
); 


我還發現格式跳躍:-fs到保護特定的代碼段從perltidy。我在這裏舉了一個例子,但網站似乎做了一個斧頭工作...