use warnings; use strict; use Hic; # sub hiccup (&@); my $lanCidr = 'WHATEVER'; my $dmzIp = 'SOMEWHERE'; my %ipAddress = qw(HERE we_are THERE it_goes EVERYWHERE at_once); my @array = qw(WIBBLE BOFF); my $s = << "EOF"; iptables -t nat -N outbound-DMZ @{[ hiccup { "iptables -t nat -s $lanCidr -o $_ -j SNAT --to-source $dmzIp" } keys %ipAddress ]} whatever else here @{[ hiccup { "flocculate -f $_ -j SNAT --to-source $dmzIp" } @array ]} iptables -t nat -A outbound-DMZ -j RETURN EOF # sub hiccup (&@) { return join "\n", map $_[0]->(), @_[ 1 .. $#_ ]; } print "[[$s]]"; #### package Hic; use warnings; use strict; use parent 'Exporter'; our $VERSION = '0.1.0'; our @EXPORT = qw(hiccup); # default exported symbol(s) our @EXPORT_OK = qw(); # optional exported symbol(s) (none) sub hiccup (&@) { return join "\n", map $_[0]->(), @_[ 1 .. $#_ ]; } 1; #### c:\@Work\Perl\monks\Anonymous Monk\1197277>perl hiccup_here_3.pl [[iptables -t nat -N outbound-DMZ iptables -t nat -s WHATEVER -o EVERYWHERE -j SNAT --to-source SOMEWHERE iptables -t nat -s WHATEVER -o THERE -j SNAT --to-source SOMEWHERE iptables -t nat -s WHATEVER -o HERE -j SNAT --to-source SOMEWHERE whatever else here flocculate -f WIBBLE -j SNAT --to-source SOMEWHERE flocculate -f BOFF -j SNAT --to-source SOMEWHERE iptables -t nat -A outbound-DMZ -j RETURN ]]