Perl-将未定义数量的字符串连接为一个字符串 [英] Perl - concatenating a undefined number of strings into one string
问题描述
我需要使用Perl连接未定义数量的字符串以创建一个更大的字符串。
I need to concatenate an undefined number of strings with Perl to create one larger string.
$ concatenated_string = $ string1。 $ string2。 $ string3
#..以此类推,该文件中提供的所有字符串均已在程序的早期打开。
$concatenated_string = $string1 . $string2 . $string3
#..and so on for all strings provided in the file which was opened earlier in the program.
我只是一个初学者,但我在这里找不到与此有关的任何问题。
I am just a beginner, but I could not find any question on here relating to it. Any help is much appreciated.
推荐答案
作为我在其他地方提到过:
当您发现自己添加变量名的整数后缀,请考虑 我应该使用数组 。
When you find yourself adding an integer suffix to variable names, think "I should have used an array".
然后您可以使用 join('',@strings)
。
Then you can use join('', @strings)
.
这篇关于Perl-将未定义数量的字符串连接为一个字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!