File::FindStrings - Finds strings within a file
version 0.100
use File::FindStrings qw(find_words_in_file); my (@matches) = find_words_in_file($file, 'foo', 'bar'); foreach my $match (@matches) { my $line = $match->{line}; my $word = $match->{word}; print "Match on line $match for $word\n"; }
This module will locate lines that match one or more of a given set of words (which are defined as strings that appear between word seperators).
Read file $file on a line by line basis, checking each line for matches on @words.
$file
@words
If the file cannot be read, an exception is thrown.
A word will match if it appears in it's entirety on a single file line, prefixed and suffixed by a word boundary (including the start or end of line). The match is case-insenstive.
This returns a list of matches. Each match is a hashref containing the keys line (line number) and word (the matched word).
line
word
Searches $string on a line by line basis, checking each line for matches on @words.
$string
A word will match if it appears in it's entirety on a single line, prefixed and suffixed by a word boundary (including the start or end of line). The match is case-insenstive.
Joelle Maslak <jmaslak@antelope.net>
This software is copyright (c) 2017 by Joelle Maslak.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Perl::Critic::Policy::BadStrings, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Perl::Critic::Policy::BadStrings
CPAN shell
perl -MCPAN -e shell install Perl::Critic::Policy::BadStrings
For more information on module installation, please visit the detailed CPAN module installation guide.