#!/opt/local/bin/perl use strict; use warnings; open my $vlan_in, '<', shift @ARGV; my @vlans = <$vlan_in>; foreach my $line (@vlans) { chomp $line; # Separate the 'vlan' from the list (and throw it away). my (undef, $vlans) = split /\s+/, $line; # Break up the list into items. my @items = split /,/, $vlans; # Print your new output. foreach my $item (@items) { next unless defined $item; $item =~ s/,//; print "vlan $item\n"; } }