Fixed a minor bug in both Ruby and Perl file