永久格式化多行



我正试图让perltidy格式化if语句,如下所示:

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)
    . ")");

像其他行一样跳到前一行:

$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

谢谢。

关于第一个问题,我没有太多可以提供的,但对于第二个问题,您是否考虑过将其重构为使用占位符?它可能会更好地格式化,自动为您报价,并为您(和您模块的用户)提供一个健康的屏障来解决SQL注入问题。

my$sth=$dbh->prepare('INSERT INTO image VALUES(NULL;$sth->执行($self->图像,$self->扩展,$selv->位置,$self->已修改,$self-->已访问);


我还发现了格式跳过:-fs来保护特定的代码段不被破坏。我在这里举了一个例子,但网站似乎对它做了一个恶搞…

相关内容

  • 没有找到相关文章

最新更新