Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Compare each array element to the rest, sequentially

by Anonymous Monk
on Dec 07, 2017 at 15:17 UTC ( [id://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 (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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1205095]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-20 01:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found