See comments.
foreach my $line (@vcvars) { if ($line =~ /^set INCLUDE=(.*)/) { ## use the ^ and $ anchors whe +never possible my @paths = split(/;/, $1); # $1 is the part in brackets in th +e regex above print VCVARS32 "set INCLUDE="; print VCVARS32 join(";", # concatenate list of strings using +semicolons grep( !/^\%SRVBUILD\%/, @paths) # return list of the strin +gs that do not start with %SRVBUILD% ); print VCVARS32 "\n"; next; } # no else{} necessary; next() will prevent you falling through to +here # in you "set SRVBUILD" case: # $line =~ s/^\=(\W*)/\=/; # this will not work since you're using an ^ anchor; # the "=" is not at the beginning of the string, is it? # also, \W matches any NONword-character; anything NOT a letter, d +igit or underscore # but if I understood correctly you want to change everything afte +r the "=" # you can simply use a s///ubstitution here # since if the left side does not match, nothing gets replaced; # no need for an if(){} s/^(set SRVBUILD)=.*/$1=INI_CODE_HERE/; # and then we can just let the boilerplate print handle the modifi +ed $line print VCVARS32 $line; }
____________
Makeshifts last the longest.

In reply to Re: How to remove middle of string? by Aristotle
in thread How to remove middle of string? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.