我正在寻找一些帮助。
要求:
通过一些验证,我在一个数组中存储了以下类型的值。
@array_name = ("Rajesh","Raju","Ram","John","peter");
现在我从一些背景知道“Rajesh”、“Ram”、“peter”是重复的条目,所以我希望我的输出是:
@array_name = ("Rajesh","Raju","John");
# or
@array_name = ("Ram","Raju","John");
# or
@array_name = ("peter","Raju","John");
我已经完成了如下示例程序,但它并不满足我...
my $spcific_output ="";
my $output ="";
foreach my $name (@array_name)
{
if($name eq "Rajesh" || $name eq "Ram" || $name eq "peter")
{
$spcific_output = "Rajesh and Ram and peter");
}
else
{
$output .= "My Name is $name";
}
}
$output .= $spcific_output;
有什么最好的方法来实现这一点?