Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6154277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:14:14+00:00 2026-05-23T20:14:14+00:00

I know there is a similar question but I took tips from there and

  • 0

I know there is a similar question but I took tips from there and applied to my code to remove the duplicates. All I am getting is just the last element of the array. I am unable to see where I am going wrong. please help me find out where a I am going wrong.

use strict;
use warnings;
use File::Find;
use Data::Dumper;
use List::MoreUtils qw/ uniq /;

my $localdir = 'images/p/';
my @filefound;
my @split1;
my $before;

find(sub {push @filefound, $File::Find::name if /.jpg$/ },$localdir);

for(@filefound) { print "$_ \n";}

foreach (@filefound){
my @result = split('_',$_);
@split1 = $result[0];
}

my %unique = ();
foreach my $item (@split1)
{ 
    $unique{$item} ++;
}

my @myuniquearray = keys %unique;
foreach (@myuniquearray){ print "$_  \n";}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T20:14:14+00:00Added an answer on May 23, 2026 at 8:14 pm

    The problem lies here:

    foreach (@filefound){
        my @result = split('_',$_);
        @split1 = $result[0];
    }
    

    You are reassigning @split1 each time through the loop. Try push @split1, $result[0]; instead to push the new element onto the existing list.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know there is a very similar question here but I was hoping to
I know there's a similar question MPMusicPlayerController stops sending notifications , but the answer
I know there are a LOT of similar question to this, but I've tried
So I know that there is a very similar question to this all over
I know there are already similar question, but none of them could solve my
I know there are several threads asking similar questions - but I havent found
I know there are many questions similar but any of them didn't help. in
I know there's a ton of similar questions on here but I reviewed a
I know there are questions similar to this one, but I've not found a
I know there have been some similar questions to this, but they haven't helped

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.