use strict; use warnings; use DBI; use Net::Telnet::Cisco; use Digest::MD5; our $dbh = DBI->connect(...) or die $DBI::errstr; my $session = Net::Telnet::Cisco-> new (Host => '10.200.2.100'); my $raw_data; sub Login{ my @output = $session->cmd('show run'); my $List = join '',@output; my @array = split /interface ATM/,$List; shift @array; my %hash; for my $interface(@array){ my ($bez) = $interface =~ /^([^\n]+)/; my @data = $interface =~ /(data.*?cbr 128)/sg; for my $data(@data){ my ($id,$ip) = $data =~ /(data\s*[\d\/]+).*?protocol ip ((?:\d{1,3}\.){3}\d{1,3})/s; push @{$hash{'ATM'.$bez}}, [$id,$ip]; } } my $query = "INSERT INTO RC_CISCO_NB(NEID,TS,VPI,VCI,PCR,data,IP) VALUES(?,NOW(),'','','',?,?)"; my $sth = $dbh->prepare($query) or die $dbh->errstr(); for my $atm(keys %hash){ print sprintf("%10s | %10s | %15s\n",$atm,'data','IP'); print sprintf("%10s | %10s | %15s\n",' ',@$_) for @{$hash{$atm}}; $sth->execute($neid,$_,$atm) or die $dbh->errstr() for(@{$hash{$atm}}); } }