in reply to Re^3: perl regular expressions
in thread perl regular expressions
Global symbol "$string" requires explicit package name at map.pl line 13. Execution of map.pl aborted due to compilation errors. Use of uninitialized value $file in open at map.pl line 8. readline() on closed filehandle $fh at map.pl line 9.
I see that you have used @string but I see $string in die "Unable to find string: $string";
use strict; use warnings; find_string { my ($file, @strings) = @_; open my $fh, '<', $file; my $re = join "|", map quotemeta, @strings; while (<$fh>) { return 1 if /$re/; } die "Unable to find string: $string"; } find_string('prepos.config', "testing","link","100K");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: perl regular expressions
by kennethk (Abbot) on Jun 24, 2014 at 18:28 UTC |