in reply to Re^2: Replace an asterisk '*" with the content of array
in thread Replace an asterisk '*" with the content of array

You need to identify the lines without * to let those pass through. Then loop over the network list but use a copy of the line in the substitution each time

#!perl use strict; my @finalnwlist = qw( 192.169.32.0/255.255.255.0 192.169.72.0/255.255.255.0 192.169.73.0/255.255.255.0); replace_exports('exports.txt'); sub replace_exports { my $filename = shift; open IN,'<',$filename or die "Error opening $filename for read : $!"; my @lines = <IN>; close IN; open OUT, '>', 'chg_'.$filename or die "Error opening $filename for write : $!"; for (@lines) { chomp; if (m/\*/){ print "Change $_\n"; for my $nw (@finalnwlist){ my $copy = $_; $copy =~ s/\*/$nw/; print OUT $copy."\n"; } } else { print OUT $_."\n"; } } close OUT }
poj