我有以下代码来打印网址:
$active_url="-http://xxxx.vim.tlt.xxxxx.it/ddts/ddts_main?bug_id=$parent&REMOTE_USER=nni&LastForm=DumpBug";
print "active_url=$active_url";
我从数据库中获取$parent
的值。但是,当我运行代码时,输出不是我所期望的:
$active_url= &REMOTE_USER=nni&LastForm=DumpBugdts/ddts_main?bug_id=ONDvx42368
当我使用Data :: Dumper打印$parent
时,我得到:
';AR1 = 'ONDvx42368
虽然我希望它能打印出类似的内容:
$VAR1 = 'ONDvx42368'
可能导致此问题的原因是什么?作为参考,这是我的完整程序及其输出:
use strict;
use DBI;
use DBD::Pg;
use Data::Dumper;
#print Dumper $relations;
my @remove;
my @temp_value;
my $relation_id=$dbh->selectrow_array("select id from customfield where cfname='Relations'");
my $ddts_id=$dbh->selectrow_array("select id from customfield where cfname='DDTS_Identifier'");
my $src_issue='PROJ-83294';
if (exists $relations->{$src_issue}->{'ddts_identifier'}) {
my @temp_value;
my $rel=$dbh->selectrow_array("XXXXX");
if($rel ne '') { # rel= PARENT-ONDvx42368\n CHILD-TSDnm47353
my @rel=split/\n/,$rel;
foreach my $relation(@rel) {
my @link=split/[- ]/,$relation; #$relation= PARENT-ONDvx42698
my $link_type=@link[0];
for(my $i=1;$i<=$#link;$i++) {
my $active_url="$link_type-@link[1]-http://tljnu.vim.tlt.alcatel.it/ddts/ddts_main?bug_id=".@link[1]."&REMOTE_USER=nm_ni&LastForm=DumpBug");
print "active_url=$active_url";
push(@temp_value,$active_url);
$relation=~ s/@link[$i]//;
}
if ($relation =~ m/[0-9]/){
push(@temp_value,$relation);
}
}
my $new_value=join("\n",@temp_value);
print "updated=$new_value\n";
}
}
&REMOTE_USER=nm_ni&LastForm=DumpBugdts/ddts_main?bug_id=ONDvx42368
答案 0 :(得分:1)
您的$parent
值结尾处似乎有换行符。
如果我添加换行符,我会得到这个
$parent = "ONDvx42368\n";
$active_url = "-http://xxxx.vim.tlt.xxxxx.it/ddts/ddts_main?bug_id=$parent&REMOTE_USER=nni&LastForm=DumpBug";
print "active_url=$active_url";
<强>输出强>
active_url=-http://xxxx.vim.tlt.xxxxx.it/ddts/ddts_main?bug_id=ONDvx42368
&REMOTE_USER=nni&LastForm=DumpBug
我建议您通过编写
确认$parent
的内容
use Data::Dumper;
$Data::Dumper::Useqq = 1;
print Dumper $parent;
,在我的情况下,输出
$VAR1 = "ONDvx42368\n";
以便新线可见。
答案 1 :(得分:0)
您可以尝试
$parent="ONDvx42368";
print qq(active_url=-http://xxxx.vim.tlt.xxxxx.it/ddts/ddts_main?bug_id=$parent&REMOTE_USER=nni&LastForm=DumpBug
);