rajeshkumar created the topic: Delete an element from array based on custom duplicate value
Hi, I am looking for some help in one scenario.
Requirement:
Through some validation, I have strored following kinds of value in one array.
@array_name = (“Rajesh”,”Raju”,”Ram”,”John”,”peter”);
Now I know from some background that “Rajesh”, “Ram”, “peter”, is duplocated entry so i would expect my output to be:
@array_name = (“Rajesh”,”Raju”,”John”);
or
@array_name = (“Ram”,”Raju”,”John”);
or
@array_name = (“peter”,”Raju”,”John”);
I have done example program such as below but it does not satisfy me…
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;
Any best way to achieve this????
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn
I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I am working at Cotocus. I blog tech insights at DevOps School, travel stories at Holiday Landmark, stock market tips at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at I reviewed , and SEO strategies at Wizbrand.
Please find my social handles as below;
Rajesh Kumar Personal Website
Rajesh Kumar at YOUTUBE
Rajesh Kumar at INSTAGRAM
Rajesh Kumar at X
Rajesh Kumar at FACEBOOK
Rajesh Kumar at LINKEDIN
Rajesh Kumar at PINTEREST
Rajesh Kumar at QUORA
Rajesh Kumar at WIZBRAND