in reply to Switch CLI Parsing Question
Test program:while ($parse =~ s!(\d{1,2})/(\d{1,2})(?:-(\d{1,2}))?!!) { $end = $3 ? $3 : $2; print "untagged Interface GigabitEthernet $1/$_\n" for ($2 .. $end) }
#!/usr/bin/perl use strict; use warnings; while (my $line = <DATA>) { chomp($line); while ($line =~ s!(\d{1,2})/(\d{1,2})(?:-(\d{1,2}))?!!) { my $slot = $1; my $port_start = $2; my $port_end = $3 ? $3 : $port_end; for my $port ($port_start .. $port_end) { print "untagged Interface GigabitEthernet $slot/$port\n"; } } } __DATA__ untagged Interface GigabitEthernet 1/2,1/3-5,1/12,1/40
|
|---|