in reply to Re^3: perl regular expressions
in thread perl regular expressions

Still not working. Not enough arguments for read near ""Unable to find string: @strings";" Execution of .pl aborted due to compilation errors.

Replies are listed 'Best First'.
Re^5: perl regular expressions
by kennethk (Abbot) on Jun 25, 2014 at 14:44 UTC
    I do not see that error; what is the exact code you have?
    sub find_string { my ($file, @strings) = @_; open my $fh, '<', $file; while (<$fh>) { for my $string (@strings) { return 1 if /\Q$string/; } } die "Unable to find string: @strings"; } find_string('filename', "testing","link","rd");
    Of course the above should be amended to test that the open worked:
    open my $fh, '<', $file or die "File open fail ($file): $!";

    #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.