我尝试执行存储在模块中的查询,但查询中有一些从主文件中读取但不起作用的变量。
模块内部无法访问主文件中的变量(空白)。
以下是代码:
sql.pm
package sql;
use parent 'Exporter';
our @EXPORT = qw(%query);
our %query = (
one => "SELECT isnull(BusinessEntityID, '') as BusinessEntityID,
isnull(Title, '') as Title,
isnull(FirstName, '') as FirstName,
isnull(LastName, '') as LastName,
isnull(Suffix, '') as Suffix,
isnull(JobTitle, '') as JobTitle
FROM HumanResources.vEmployee
where BusinessEntityID = ".$id."
order by BusinessEntityID"
);
1;
main.pl
use strict;
use warnings;
use sql;
my $id = 273;
my $query_main = "$query{one}";
print $query_main;
这将打印查询,其中BusinessEntityID =而不是BusinessEntityID = 273
谢谢!