package MyControl; use Net::Telnet; sub doit { my $t = new Net::Telnet(Timeout=>500); $t->open("lin.ux.box.ip") or die $!; # $t->login("user id","password"); # replace ls -al below with /usr/bin/perl as reqd chomp(my @oldls = $t->cmd("ls -al")); my $lsstr = join "\n", map { $_ . ") " . $oldls[$_] } (0 .. $#oldls); $t->close(); return $lsstr; }