=================================================================== RCS file: /cvs/trango/Net-Telnet-Trango/lib/Net/Telnet/Trango.pm,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- trango/Net-Telnet-Trango/lib/Net/Telnet/Trango.pm 2007/01/17 23:15:13 1.26 +++ trango/Net-Telnet-Trango/lib/Net/Telnet/Trango.pm 2007/01/31 18:53:29 1.27 @@ -1,5 +1,5 @@ package Net::Telnet::Trango; -# $RedRiver: Trango.pm,v 1.25 2007/01/17 20:48:46 andrew Exp $ +# $RedRiver: Trango.pm,v 1.26 2007/01/17 23:15:13 andrew Exp $ use strict; use warnings; use base 'Net::Telnet'; @@ -65,8 +65,8 @@ It also takes an optional parameter 'Decode'. If not defined it defaults to 1, if it is set to 0, it will not decode the output and -instead return an array of the lines that were returned from the -command. +instead return a reference to an array of the lines that were returned +from the command. =cut @@ -179,10 +179,6 @@ =over -=item B - -- returns the name of the host that you are accessing - =item B - returns the firmware version @@ -342,7 +338,7 @@ =cut -my $success = 'Success.'; +my $success = 'Success\\.'; my %COMMANDS = ( tftpd => { decode => 'all', expect => $success }, ver => { decode => 'all' }, @@ -371,12 +367,12 @@ my %ALIASES = ( bye => 'exit', restart => 'reboot', + Host => 'host', ); my %ACCESS = map { $_ => 1 } qw( firmware_version host_type - Host is_connected logged_in login_banner @@ -431,7 +427,7 @@ my $self = shift; unless ( $self->SUPER::open(@_) ) { - $self->last_error("Couldn't connect to " . $self->Host . ": $!"); + $self->last_error("Couldn't connect to " . $self->host . ": $!"); return undef; } @@ -440,7 +436,7 @@ -match => '/password: ?$/i', -errmode => "return", ) ) { - $self->last_error("problem connecting to host (" . $self->Host . "): " . + $self->last_error("problem connecting to host (" . $self->host . "): " . $self->lastline); return undef; } @@ -478,7 +474,7 @@ -match => $self->prompt, -errmode => "return", ) ) { - $self->last_error("login ($self->Host) failed: " . $self->lastline); + $self->last_error("login ($self->host) failed: " . $self->lastline); return undef; } @@ -621,7 +617,7 @@ return undef unless @lines; unless ($PRIVATE{'Decode'}) { - return @lines; + return \@lines; } my @sus; @@ -976,7 +972,7 @@ if ($PRIVATE{'Decode'} && $cfg{'decode'}) { return $vals; } else { - return @lines; + return \@lines; } } else { $self->last_error("Error with command ($cfg{'String'}): $last"); @@ -994,6 +990,7 @@ my $key = ''; my $val = undef; + my @vals; my $in_key = 0; my $in_val = 1; @@ -1018,7 +1015,7 @@ $key =~ s/^\s+//; $key =~ s/\s+$//; - if (defined $val) { + if ($val) { $val =~ s/^\s+//; $val =~ s/\s+$//; } @@ -1030,11 +1027,13 @@ $key = $new . " " . $key; } - $last_key = $key; $conf{$key} = $val; + $last_key = $key; $key = ''; - $val = ''; - } + } elsif ($val) { + push @vals, $val; + } + $val = ''; } elsif ($c eq ']') { $in_val = 1; @@ -1050,7 +1049,20 @@ } } + unless ($key) { + push @vals, $val; + } + + if (@vals == 1) { + $val = $vals[0]; + } elsif (@vals) { + $val= \@vals; + } else { + $val = undef; + } + if (%conf) { + $conf{_pre} = $val if $val; return \%conf; } else { return $val;