in reply to replace separator from array elements

Don't bother replacing the "," with a vlan. Since the text is repetitive, and can be inferred by context, just store the numbers, as so:

#!/usr/bin/perl use warnings; use strict; my @vlans = (); while(<DATA>) { chomp; s/vlan //i; my @data = split/\,/, $_; foreach my $dat (@data) { push @vlans, $dat; } } for(@vlans) { print "vlan ", $_, "\n"; } __DATA__ vlan 107 vlan 121 vlan 122,127,129,137
The output is:

C:\Code>perl vlanlist.pl vlan 107 vlan 121 vlan 122 vlan 127 vlan 129 vlan 137