in reply to Switch CLI Parsing Question

Not the most elegant solution, and probably a lot more verbose than it needs to be - but appears to give the desired result...
#!/usr/bin/perl use warnings; use strict; while (my $line = <DATA>) { chomp($line); my @parts = split /\s/, $line, 4; for (split /,/, $parts[3]) { my ($slot, @ports) = split /\//; if ($ports[0] =~ /(\d+)-(\d+)/) { @ports = ($1 .. $2); } for my $port (0 .. $#ports) { print join(' ', @parts[0..2], "$slot/$ports[$port]\n"); } } } __DATA__ untagged Interface GigabitEthernet 1/2,1/3-5,1/12,1/40

Output:

untagged Interface GigabitEthernet 1/2 untagged Interface GigabitEthernet 1/3 untagged Interface GigabitEthernet 1/4 untagged Interface GigabitEthernet 1/5 untagged Interface GigabitEthernet 1/12 untagged Interface GigabitEthernet 1/40

I'd suggest testing with more data before using it.
Hope this helps,
Darren :)