in reply to character location question
updated: ()my $i = index reverse($phrase),$what;
use strict; print join(",",rindexes("hello world , kill bill","ll")); sub rindexes { my $s = reverse shift; my $what = reverse shift; my @indexes; my $old = 0; while ((my $i = index $s,$what,$old) > -1) { push @indexes, length($s) - $i - length($what) +1; $old = $i+1; } @indexes; }
|
|---|