in reply to Re: Replace an asterisk '*" with the content of array
in thread Replace an asterisk '*" with the content of array
You're losing the comment line.
use 5.16.2; my @finalnwlist = ( '192.169.32.0/255.255.255.0', '192.169.72.0/255.255.255.0', '192.169.73.0/255.255.255.0'); my @output = replace_exports(); use Data::Dumper; say Dumper \@output; sub replace_exports { chomp(my @lines = <DATA>); my @changes; foreach my $line (@lines) { if ($line !~ /\*/) { push(@changes,$line) } else { foreach my $server (@finalnwlist) { my $output = $line; $output =~ s/\*/$server/g; push(@changes,$output); } } } return @changes; } __DATA__ /file1 *(rw,sync,no_root_squash,no_subtree_check) /file2 *(ro,sync,no_root_squash,no_subtree_check) # shares for Tsp InstallServer file3 *(ro,sync,no_subtree_check)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Replace an asterisk '*" with the content of array
by SimonPratt (Friar) on Sep 18, 2015 at 14:33 UTC |