in reply to Switch CLI Parsing Question

Here is one way to do it, inspired by number sequence.

use strict; use warnings; my $in = '1/2,1/3-5,1/12,1/40'; my @munged = map { my ( $slot, $portstr ) = split( '/', $_ ); my @ports = ( $portstr =~ m/(\d+)-(\d+)/ ) ? $1 .. $2 : $ports +tr; map { join( '/', $slot, $_ ) } @ports; } split( ',', $in ); print "$_\n" for @munged;
It could be shortened, of course, if length is an issue.

You could also play with Set::IntSpan (as I mentioned in the aforementioned thread).