use warnings;
use strict;
use autodie;
+use Data::Dump qw(dump);
-# ./sw-name-mac.sh
-# ./sw-names | xargs -i ./dell-switch.pl {} 'show lldp neighbors'
-# /home/dpavlin/mikrotik-switch/m-neighbour
+if ( $ARGV[0] eq 'update' ) {
+ print <<__SH__
+./sw-name-mac.sh
+./sw-names | xargs -i ./dell-switch.pl {} 'show lldp neighbors'
+/home/dpavlin/mikrotik-switch/m-neighbour
+__SH__
+ ;
+ exit 0;
+};
-use Data::Dump qw(dump);
my $debug = $ENV{DEBUG} || 0;
sub mac2name {
my ( $mac, $name ) = @_;
+ return unless defined $mac;
$mac = lc($mac);
# prase MikroTik /ip neighbor print detail terse
-foreach my $file ( glob('../mikrotik-switch/out/*neighbor*'), glob('../tilera/out/*neighbor*') ) {
- my $name = $1 if $file =~ m{out/([\w\-]+)\.ip neighbor};
+my $patt = 'ip neighbor print detail terse';
+$patt =~ s{\s}{\\ }g; # escape spaces
+my @files = ( map { $_ . '/*' . $patt } qw( ../mikrotik-switch/out/ ../tilera/out/ ));
+@files = map { glob $_ } @files;
+warn "XXX $patt files=",dump(\@files) if $debug;
+
+foreach my $file ( @files ) {
+ my $name = $1 if $file =~ m{out/+([\w\-]+)\.ip neighbor};
print "## [$name] file $file\n" if $debug;
open(my $f, '<', $file);
while(<$f>) {