Change $_ = $key to fit perl 5.14
Change scalar assignment to scalar
As push $arr_ref (perl >= 5.14) is used, change use
IO::Scalar is used for testing