use Benchmark qw(:all); my @lines = split /\n/, < sub { my @copy = @lines; foreach my $line (@copy) { my (undef, $vlans) = split /\s+/, $line; my @items = split /,/, $vlans; } }, '/g' => sub { my @copy = @lines; foreach my $line (@copy) { my @items = ($line =~ /(\d+)/g); } }, 'sub-split' => sub { my @copy = @lines; foreach my $line (@copy) { s/vlan //; my @items = split /,/, $line; } }, } );