in reply to Compare each array element to the rest, sequentially

Ok, I actually do it like this:
for ($i=0; $i<=$#all_IDS; $i++) { $current_ID = $all_IDS[$i]; splice(@all_IDS,$i,1); print $current_ID,"\n######\n"; print "@all_IDS\n"; print "@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"; push @all_IDS, $current_ID; }

and it works.

Replies are listed 'Best First'.
Re^2: Compare each array element to the rest, sequentially
by poj (Abbot) on Dec 07, 2017 at 16:27 UTC
    and it works.

    Are you sure ?. Try

    #!/usr/bin/perl use strict; use Text::Levenshtein qw(distance); my $file = $ARGV[0]; open IN, '<',$file or die "$!"; chomp(my @all_IDS=<IN>); close IN; for (0..$#all_IDS){ my $id = shift @all_IDS; my @ld = distance ($id, @all_IDS); print join "\t",$id,@all_IDS,@ld,"\n"; push @all_IDS,$id; } __DATA__ A BB CCC DDDD
    Result
    A       BB      CCC     DDDD    2       3       4
    BB      CCC     DDDD    A       3       4       2
    CCC     DDDD    A       BB      4       3       3
    DDDD    A       BB      CCC     4       4       4
    
    poj