Slide 1
Most trusted JOB oriented professional program
DevOps Certified Professional (DCP)

Take your first step into the world of DevOps with this course, which will help you to learn about the methodologies and tools used to develop, deploy, and operate high-quality software.

Slide 2
DevOps to DevSecOps – Learn the evolution
DevSecOps Certified Professional (DSOCP)

Learn to automate security into a fast-paced DevOps environment using various open-source tools and scripts.

Slide 2
Get certified in the new tech skill to rule the industry
Site Reliability Engineering (SRE) Certified Professional

A method of measuring and achieving reliability through engineering and operations work – developed by Google to manage services.

Slide 2
Master the art of DevOps
Master in DevOps Engineering (MDE)

Get enrolled for the most advanced and only course in the WORLD which can make you an expert and proficient Architect in DevOps, DevSecOps and Site Reliability Engineering (SRE) principles together.

Slide 2
Gain expertise and certified yourself
Azure DevOps Solutions Expert

Learn about the DevOps services available on Azure and how you can use them to make your workflow more efficient.

Slide 3
Learn and get certified
AWS Certified DevOps Professional

Learn about the DevOps services offered by AWS and how you can use them to make your workflow more efficient.

previous arrow
next arrow

Remove the duplicate data from array using perl

Spread the Knowledge

rajeshkumar created the topic: Remove the duplicate data from array using perl

Remove the duplicate data from array using perl

Method 1
============================================
sub uniqueentr
{
return keys %{{ map { $_ => 1 } @_ }};
}

@array = ("perl","php","perl","asp”);

print join(" ", @array), "\n";
print join(" ", uniqueentr(@array)), "\n";

Method 2
============================================
sub uniq {
return keys %{{ map { $_ => 1 } @_ }};
}

@my_array = ("one","two","three","two","three");
print join(" ", @my_array), "\n";
print join(" ", uniq(@my_array)), "\n";

Method 3
============================================
sub uniq2 {
my %seen = ();
my @r = ();
foreach my $a (@_) {
unless ($seen{$a}) {
push @r, $a;
$seen{$a} = 1;
}
}
return @r;
}
@my_array = ("one","two","three","two","three");
print join(" ", @my_array), "\n";
print join(" ", uniq2(@my_array)), "\n";

Method 4
============================================
my %unique = ();
foreach my $item (@myarray)
{
$unique{$item} ++;
}
my @myuniquearray = keys %unique;

Method 5
============================================
sub duplicate {
my @args = @_;
my %items;
for my $element(@args) {
$items{$element}++;
}
return grep {$items{$_} > 1} keys %items;
}

Method 6
============================================
#! /usr/bin/perl -w

use strict;

sub uniq{
my %temp_hash = map { $_, 0 } @_;
return keys %temp_hash;
}

my @test_array = qw/ 1 3 2 4 3 2 4 7 8 2 3 4 2 3 2 3 2 1 1 1 /;
my @uniq_array = uniq(@test_array);
print "@uniq_array\n";

Method 7
============================================
%seen=();
@unique = grep { !$seen{$_} ++ } @array;

Method 8
============================================
my @in=qw(1 3 4 6 2 4 3 2 6 3 2 3 4 4 3 2 5 5 32 3); #Sample data
my @out=keys %{{ map{$_=>1}@in}}; # Perform PFM
print join ' ', sort{$a<=>$b} @out;# Print data back out sorted and in order.

Reference:
Different Source of Google Search

Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Rajesh Kumar