in reply to Golf: Fuzzy finder / autocomplete
#!/usr/bin/perl -l @ARGV=qw(mig main_generator migrations django_migrations django_admin_ +log myfoo\bar.txt ); @c=split//,shift;print for map$_->[0],grep$_->[2]>0,sort{$a->[2]<=>$b- +>[2]or$a->[1]<=>$b->[1]} map{my$p;$s=$_;my@d;$p>=0 and push@d,$p=index$s,$_,$p for@c;[$s,$d[0], +$d[-1]-$d[0]]}@ARGV
Update: Fixed to handle xmxgx: index accepts negative positions and treats them as 0.
|
|---|