while(1) { my $chr = getch(); if($chr ne "\n") { push(@someary, $chr); } else { print "\n" last; } }