# URI::Template の最新版(0.21)で variables メソッドの挙動が変わっている件 {{tag: perl, cpan}} [[https://github.com/bricas/uri-template/commit/4e3fbd4c9f219260229d8f7a391ad1f3c1f127ff この差分]] に起因する振る舞いの違いなんだけど、 sub variables { - return keys %{ $_[ 0 ]->{ _vars } }; + return sort {$_[ 0 ]->{ _vars }->{ $a } <=> $_[ 0 ]->{ _vars }->{ $b } } keys %{ $_[ 0 ]->{ _vars } }; } `keys` はスカラコンテキストでリストの数を返すのだけど、`sort` は undef を返すという違いがあって(なんと!)、 if ( $uri_template_obj->variables ) { # something } みたいなことをやってると挙動変わってるのにハマる可能性ある。 $ perldoc -f sort In list context, this sorts the LIST and returns the sorted list value. In scalar context, the behaviour of "sort()" is undefined. うぇぇぇい。 ---------- 追記 [[https://github.com/bricas/uri-template/commit/2fcc32938afea1c4f9379803118d3f7b0a0aab01 issue あげといたら速攻対応してもらえた]] 。0.22 で 0.20 までと同じ挙動になってます。