dgrunwal has asked for the wisdom of the Perl Monks concerning the following question:
Error: Global symbol "@patterns" requires explicit package name at pattern2.pl line 7. Global symbol "@patterns" requires explicit package name at pattern2.pl line 14. syntax error at pattern2.pl line 14, near ");" Execution of pattern2.pl aborted due to compilation errors. What syntax error am I making? Best, Daviduse strict; use warnings; sub main { my @patterns = ("^abd", "ghi"); my $file = 'C:\Perl64\bin\hello.txt'; open(FH, $file) or die("File $file not found"); while(my $String = <FH>) { # if($String = ~ /^abd /) if($String .= join ('/ && /', @patterns); { print "$String \n"; } } close(FH); } main();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Providing regex using an array
by haukex (Archbishop) on Sep 09, 2022 at 22:12 UTC | |
|
Re: Providing regex using an array
by LanX (Saint) on Sep 10, 2022 at 00:17 UTC | |
by dgrunwal (Initiate) on Sep 11, 2022 at 20:00 UTC |