The for is apparently just being used as a topicalizer here. So if you rewrite the first code example in "normal" Perl, it's
if ( $sFunction =~ /test1/ ) { # ... } if ( $sFunction =~ /test2/ ) { # ... }
So then it becomes more clear that one possibility of several for rewriting the logic is the following, where one could even consider to put $sFunction =~ /test2/ into a variable to avoid invoking the regex engine twice:
if ( $sFunction =~ /test1/ || $sFunction =~ /test2/ ) { # ... if ( $sFunction =~ /test2/ ) { # ... } }
Or, assuming your regexes have something in common like these example regexes, you can even write something like:
if ( my ($num) = $sFunction =~ /test([12])/ ) { # ... if ( $num eq "2" ) { # ... } }
In reply to Re: recursive call of current script
by haukex
in thread recursive call of current script
by feumw
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |