# Build up the match string portion of the iptables command: my @addresses2 = @$addresses; # Before Splice take backup into another variable while (scalar @addresses2) { my $matchString = "-m state"; $matchString .= " --state NEW"; $matchString .= " -m ${transport}"; $matchString .= " --protocol ${transport}"; $matchString .= " --dport ${portNum}"; $matchString .= " -s " . join(',', splice(@addresses2, 0, 50)); $matchString .= " -j ACCEPT"; # # Build the full command: my $cmd = "${appendCmd} --match=\"${matchString}\"";