简体   繁体   English

串联未按预期在perl中工作

[英]concatenation is not working as expected in perl

Here is a simple piece of code in perl. 这是perl中的简单代码。 Here I can print the value of the key, however I am never able to concatenate $key with $value. 在这里我可以打印键的值,但是我永远无法将$ key与$ value连接起来。 Whenever I try to do it the value of $key is not concatenated.Only the $value part gets printed.Can someone please help. 每当我尝试执行此操作时,$ key的值都不会连接在一起。只有$ value部分会被打印出来。 This doesnt work with join either. 这也不适用于join。

while(my ($key, $value) = each(%symbol_map)) {
  print $key."\n";
  print $key.$value."\n";
  print $DATA_OUT $key." ".$value . "\n";
}

Are you sure that your hash is properly defined? 您确定哈希定义正确吗?

Try inserting %ENV instead of %symbol_map to see if it will then list your environment correctly. 尝试插入%ENV而不是%symbol_map以查看它是否可以正确列出您的环境。 It does so for me. 对我来说就是这样。

I am guessing that your symbol table contains: 我猜您的符号表包含:

("" =>  "HB1 HKFD HKFE 130 830 HKFD")

instead of: 代替:

("134173" =>  "HB1 HKFD HKFE 130 830 HKFD")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM