in reply to output differs in perl version

This code works in perl 5.10.1.. but not in perl 5.8.8

How does it fail with 5.8.8?

I cant upgrade it to latest version, since i m running under my college server.

Yes you can(*), with App::perlbrew. It lets you easily build and install a perl in your home directory.

(*) unless your home directory does not allow exectuable files, but that's only rarely the case.