>>262
undef $/; を BEGIN {} で囲むとどういう効果があるんでしょうか。
あと、s/\n+$/\n/s
これって、文中の \n+$ にはマッチしないんでしょうか?
\Z Match only at end of string, or before newline at the end
\z Match only at end of string
を使わなきゃいけないような気がするんですが。