I made a few corrections for you below. "diagnostics" just gives a more verbose explanation of error messages. I don't use it.
#!/usr/bin/perl # Demonstrate different loops for use with string substitutions use strict; use warnings; # use diagnostics; my $NewRev = "\tabc\tkis17.1.33en_12345.exe<h href"; my $RedirectUrl; s/.*kis17/17/, s/.exe//, s/en_/./ for $NewRev; #you assigned null to $ +NewRev print "for at the end: \$NewRev = <$NewRev>\n\n"; $NewRev = "\tabc\tkis17.1.33en_12345.exe<h href"; #set back to origina +l $RedirectUrl = $NewRev =~ s/.*kis17/17/r =~ s/.exe//r =~ s/en_/./r ; print "run on line: \$RedirectUrl = <$RedirectUrl>\n"; #modified print "run on line: \$NewRev = <$NewRev>\n\n"; #not modified $NewRev = "\tabc\tkis17.1.33en_12345.exe<h href"; #set back to origina +l for ($NewRev) {s/.*kis17/17/; s/.exe//; s/en_//; } print "for at the start: \$NewRev = <$NewRev>\n\n"; $NewRev = "\tabc\tkis17.1.33en_12345.exe<h href"; #set back to origina +l for ($NewRev) #white spaces consumes no Mips! why so compact? { s/.*kis17/17/; #all 3 statements modify $NewRev s/.exe//; s/en_//; } print "for at the start: \$NewRev = <$NewRev>\n\n"; __END__ Need __END__ not just END But of course __END__ is optional, just use it like this when you want to put something in the code like an example printout Prints: for at the end: $NewRev = <17.1.33.12345<h href> run on line: $RedirectUrl = <17.1.33.12345<h href> run on line: $NewRev = < abc kis17.1.33en_12345.exe<h href> for at the start: $NewRev = <17.1.3312345<h href> for at the start: $NewRev = <17.1.3312345<h href>

In reply to Re: Need help with loop syntax errors by Marshall
in thread Need help with loop syntax errors by Todd Chester

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.