>>825 Perl5

for (<DATA>) {
 chomp;
 %h = map{$_ => [split'']} qw{trick treat};
 $k = 'none';
 for $c (split'') {
  for (keys %h) {
   $r = $h{$_};
   shift(@$r) if $c eq $$r[0];
   unless (@$r) { $k = $_; goto L }
  }
 }
L: print "$_ -> $k\n";
}
__DATA__
trick or treat
. tr ick
ttrriecatk
tri kc eat
my money

実行結果
~ $ perl 18_825_trickOrTreat.pl
trick or treat -> trick
. tr ick -> trick
ttrriecatk -> treat
tri kc eat -> treat
my money -> none