#!/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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |