Skip to content

Manu Mathew

Perl/PHP Developer

  • Home
  • Diary
    • Perl Scripts
    • PHP Scripts
    • MySQL Queries
    • jQuery
    • JavaScripts
    • HTML & CSS
  • Default Functions
  • About My Site

Tag Archives: Duplicate value removal from array in perl

Remove duplicate value from an array in perl

April 1, 2021Perl ScriptsDuplicate value removal from array in perl, Perl ScriptsWhiteWind

Remove duplicate value from an array in perl

 

#!/usr/bin/perl -w
use strict;
use warnings;
sub unique {
    my %seen;
    grep !$seen{$_}++, @_;
}

my @array = qw(one two three two three);
my @filtered = unique(@array);

print @filtered . "\n";

Output:-

one two three

Share this:

  • Click to share on WhatsApp (Opens in new window) WhatsApp
  • Click to share on Telegram (Opens in new window) Telegram
  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Pinterest (Opens in new window) Pinterest
  • Click to share on Tumblr (Opens in new window) Tumblr
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to email a link to a friend (Opens in new window) Email
  • Click to print (Opens in new window) Print

Like this:

Like Loading...
Leave a comment

RSS feed RSS - Posts

Follow me on Twitter

My Tweets
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Tags

  • Captcha
  • Duplicate value removal from array in perl
  • HTML & CSS
  • Java Scripts
  • jQuery
  • MySQL Queries
  • Perl Scripts
  • PHP Scripts
  • Uncategorized
About My Site Proudly powered by WordPress
 

Loading Comments...
 

You must be logged in to post a comment.

    %d