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

So building on Re^3: Replace an asterisk '*" with the content of array

The script should check each line

I see you have that in the program foreach(@lines)

replace '*' with each of the subnet value and should do the same for all the subnets for all the shares

this part needs more clarity / explanation and comparison to the code in Re: Replace an asterisk '*" with the content of array
  • Comment on Re^3: Replace an asterisk '*" with the content of array

Replies are listed 'Best First'.
Re^4: Replace an asterisk '*" with the content of array
by Anonymous Monk on Sep 18, 2015 at 11:01 UTC
    Well :) I gotta go so I'll leave you with my thinking :D

    So asterix line, is duplicated for each subnet, and in each duplicate the asterix is replaced with the current subnet

    Call me Teddy Bear ;)

Re^4: Replace an asterisk '*" with the content of array
by deep27ak (Novice) on Sep 19, 2015 at 05:54 UTC

    Thanks for looking into my script, I got it was I was looking for, the script was good with few mistakes but the main problem was that my array was treating the complete list of ip and subnets as 1 element so had to split them and everything worked out fine

    final script
    my @finalnwlist = split (/\n/, join (' ', @networklist, @brnwlist, @vn +wlist)); my @entries; sub update_exports { my $exports = 'exports'; open (EXPORTS,"<exports") ||die "Error opening exports file"; my @lines = <EXPORTS>; close (EXPORTS); open (TMP_EXP, ">> exports_tmp") || die "File not found"; foreach $a (@lines) { if ( $a =~ m/\*/) { logmsg "Generating unrestricted entry.."; my ($share, $permission) = split (/\*/, $a); for my $b (@finalnwlist) { @entries = join ('', $share, $b, $permission) +; print TMP_EXP @entries; } } else { print TMP_EXP $a; } } close(TMP_EXP); }