Instead of above one, i want to keep it simple as follows: print "$path_name\n" if ( $x =~ /test$/) foreach my $x (@names) # Not working print "$path_name\n" if ( /test$/) foreach (@names) # Not working. I appreciate your suggestions to optimize it.foreach my $x (@names) { if ( $x =~ /test$/) { print "$path_name\n"; } }
In reply to Concise foreach expression by ram31
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |