#!/usr/bin/perl -w use Net::Telnet::Cisco; use strict; #use Data::Dumper; my $session = Net::Telnet::Cisco-> new (Host => '10.200.2.100'); $session->login('admin', 'cisco'); # Execute a command my @output = $session->cmd('show run'); my $string = join '',@output; my @infos = split /interface ATM/,$string; shift @infos; my %hash; for my $interface(@infos){ my ($bez) = $interface =~ /^([^\n]+)/; my @pvcs = $interface =~ /(pvc.*?cbr 128)/sg; for my $pvc(@pvcs){ my ($id,$ip) = $pvc =~ /(pvc\s*[\d\/]+).*?protocol ip ((?:\d{1,3}\.){3}\d{1,3})/s; push @{$hash{'ATM'.$bez}}, [$id,$ip]; } } for my $atm(keys %hash){ print sprintf("%10s | %10s | %15s\n",$atm,'PVC','IP'); print sprintf("%10s | %10s | %15s\n",' ',@$_) for @{$hash{$atm}}; }