http://www.perlmonks.org?node_id=989676


in reply to Re^4: NET::OpenSSH to execute multiple commands
in thread NET::OpenSSH to execute multiple commands

Try changing $Line2 to $Line in the following:

if ( $Line2 =~ m/^hostname / ) { @Data2 = split( ' ', $Line2 ); $Rname = $Data2[ 2 ] ; last ; }