@filename = grep { $_ =~ /\.txt$/ } readdir DIR ;
@filename = grep { /\.txt$/ } readdir DIR ;

上二つは同じ意味なのでしょうか?
そうだとしたら、下の方はどこで比較対象を決めているのですか?