in reply to Re^3: Need help with loop syntax errors
in thread Need help with loop syntax errors
ooops. Now it is clear. And I got it all working. Thank you!
#!/usr/bin/perl # Demonstrate different loops for use with string substitutions use strict; use warnings; # use diagnostics; my $RevStr = "\tabc\tkis17.1.33en_12345.exe<h href"; my $NewRev; print "Original \$RevStr = <$RevStr>\n"; $NewRev = $RevStr; s/.*kis17/17/, s/.exe//, s/en_/./, s/\<h.*// for $NewRev; print "for at the end: \$NewRev = <$NewRev>\n"; $NewRev = $RevStr; $NewRev = $RevStr =~ s/.*kis17/17/r =~ s/.exe.*//r =~ s/en_/./r; print "run on line: \$NewRev = <$NewRev>\n"; #modified $NewRev = $RevStr; for ($NewRev) {s/.*kis17/17/; s/.exe.*//; s/en_/./; s/\<h.*//; } print "for at the start: \$NewRev = <$NewRev>\n"; $NewRev = $RevStr; 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__
./LeftToRight.pl
Original $RevStr = < abc kis17.1.33en_12345.exe<h href>
for at the end: $NewRev = <17.1.33.12345>
run on line: $NewRev = <17.1.33.12345>
for at the start: $NewRev = <17.1.33.12345>
for at the start: $NewRev = <17.1.33.12345>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Need help with loop syntax errors
by Marshall (Canon) on Sep 13, 2016 at 03:42 UTC |