Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: how to guess mutual frases?

by choroba (Abbot)
on Jul 30, 2013 at 11:38 UTC ( #1046994=note: print w/ replies, xml ) Need Help??


in reply to how to guess mutual frases?

If the file names are of the same length, you can just walk over them character by character and keep only those that are different.

#!/usr/bin/perl use warnings; use strict; my @files = qw( hhk_1sss-(hello).txt hhk_2abc-(hello).txt hhk_3xyz-(hello).txt ); my @short = @files; my $pos = 0; my $file = shift @short; while ($pos < length $file and '.' ne substr $file, $pos, 1) { my $char = substr $file, $pos, 1; if (@short == grep $char eq substr($_, $pos, 1), @short) { substr $_, $pos, 1, q() for $file, @short; } else { $pos++; } } unshift @short, $file; while (@files) { my $old = shift @files; my $new = shift @short; print "rename $old $new\n"; }
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ


Comment on Re: how to guess mutual frases?
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (16)
As of 2014-07-11 17:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (232 votes), past polls