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 8142955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:58:03+00:00 2026-06-06T12:58:03+00:00

use Modern::Perl; use Algorithm::Permute; use List::AllUtils qw/uniq/; find_perms(1151); sub find_perms { my ($value) =

  • 0
use Modern::Perl;
use Algorithm::Permute;
use List::AllUtils qw/uniq/;

find_perms(1151);

sub find_perms { 
  my ($value) = @_;
  my @others;
  my @digits = split(//, $value);

  my $perm = Algorithm::Permute->new( \@digits );

  while (my @next = $perm->next()) { 
    my $number = join('', @next);
    push @others, $number;
  }
  @others = sort uniq @others;

  # this one works correctly
  # @others = sort ( uniq( @others ));

  say "FOUND @others";
}

Output:
FOUND 1115 1115 1115 1115 1115 1115 1151 1151 1151 1151 1151 1151 1511 1511 1511 1511 1511 1511 5111 5111 5111 5111 5111 5111

Hi,

After discovering out that Algorithm::Permute is producing duplicates, most likely due to the amount of ‘1’s in “1151” i decided to use uniq. However using sort uniq without the parenthesis doesn’t produce expected results. But sort(uniq(@x)) does. What gives?

  • 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-06-06T12:58:05+00:00Added an answer on June 6, 2026 at 12:58 pm

    perldoc -f sort lists three syntaxes for the sort function:

    sort SUBNAME LIST
    sort BLOCK LIST
    sort LIST
    

    sort uniq @others matches the sort SUBNAME LIST syntax of sort. It expects uniq to be a function that compares the global variables $a and $b, and returns <0, 0, or >0 to indicate the relative ordering of $a and $b.

    It looks like you were expecting and wanting the sort LIST syntax, which is what you get when you say one of

    sort(uniq(@others))
    sort(uniq @others)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was just wondering if this is posssible: use Modern::Perl; my @list = ('a'
use Modern::Perl; use DateTime; use autodie; my $dt; open my $fh, '<', 'data.txt'; #
#!/usr/bin/perl use Modern::Perl; while (<>) { chomp; say reverse; } The above code doesn't
Is there any reason to use Dynamic Data Exchange (DDE) in a modern Windows
For desktop browser all modern browser uses Zoom functionality so we can use PX
I use the modern theme I have a livechat button on the header and
I use Java in this question but this really applies to all modern app
What do modern companies use to compile and link their projects? Especially with large
Many modern frameworks (Spring, Hibernate) provide very nice dynamic behaviors with use of Java
I use genetic algorithm in order to solve the NP-hard problem. In fact, it

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.