Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Compare each array element to the rest, sequentially

by Anonymous Monk
on Dec 07, 2017 at 15:17 UTC ( #1205095=note: print w/replies, xml ) Need Help??


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 (Monsignor) 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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1205095]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (3)
As of 2018-07-19 10:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (406 votes). Check out past polls.

    Notices?