๐Ÿš€ DevOps & SRE Certification Program ๐Ÿ“… Starting: 1st of Every Month ๐Ÿค +91 8409492687 ๐Ÿ” Contact@DevOpsSchool.com

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours scrolling social media and waste money on things we forget, but wonโ€™t spend 30 minutes a day earning certifications that can change our lives.
Master in DevOps, SRE, DevSecOps & MLOps by DevOpsSchool!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

Delete an element from array based on custom duplicate value

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

Subscribe
Notify of
guest


0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments

Certification Courses

DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:

DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.

0
Would love your thoughts, please comment.x
()
x