Insted do as follows sub handle_connection { my $x = shift; while ( <$x> ) { print $x "Testing\n"; } }