sub telnet_login # opens a telnet session to "host" { use Net::Telnet; # initialize the telnet module my ($username, $password, $host, $shell) = @_; # takes function arguments and stores them into appropriate variables $$shell = new Net::Telnet ('Timeout'=>'7', 'Errmode'=> sub { report_error("telnet","Username or Password failed"); }, 'Prompt'=> '/.*([\$#\%>~]|\@\w~\$|\\\[\\e\[0m\\\] \[0m)\s?/' ); # initalizes a telnet object sets a prompt to expect sets a timeout sets error-checking $$shell->open(Host=>$host); # opens the object $$shell->login($username,$password); # login to the telnet session }