我通過我的代碼庫中的各種代碼段擁有以下結構。 heredoc的使用對我自己和其他人來說都是有用的,能夠理解代碼,但爲通過網絡將數據傳輸到數據庫提供了不必要的批量。在'使用常量'中從perl heredoc中刪除無關空間的perl語法是什麼
use constant FIND_OBJECTS_SQL => <<' END_SQL';
select object_name
,object_type
,0 PAC_REF
,owner
from all_objects
where (object_name like upper(:1)
or object_name = upper(:1))
and object_type not in ('SYNONYM'
,'PACKAGE BODY')
END_SQL
$object_data = $dbh->selectall_arrayref(FIND_OBJECTS_SQL, $object_name);
將「s/\ s +// g」搜索和替換運算符應用於賦值的語法是什麼?
以下兩次嘗試不起作用。
use constant FIND_OBJECTS_SQL => s/\s+/ /g <<' END_SQL';
產生
Use of uninitialized value $_ in substitution (s///) at U:\junk.pl line 5.
Argument " END_SQL" isn't numeric in left bitshift (<<) at U:\junk.pl line 5.
和
use constant FIND_OBJECTS_SQL => <<' END_SQL' =~ s/\s+/ /g;
產生
Can't modify constant item in substitution (s///) at U:\junk.pl line 15, near "s/\s+/ /g;"
直到[5.14.0](http://perldoc.perl.org/perl5140delta.html#)纔會添加'/ r'選項常用表達)。 – ThisSuitIsBlackNot 2015-02-07 12:20:36
感謝您的澄清。 – DavidO 2015-02-07 16:52:30
如果您不記得每個新的非[特徵](http://perldoc.perl.org)的版本,則可以使用[Syntax :: Construct](http://p3rl.org/Syntax::Construct) /feature.html)功能。 – choroba 2015-02-17 09:04:18