The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

File::FindStrings - Finds strings within a file

VERSION

version 1.000

SYNOPSIS

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";
}

DESCRIPTION

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).

FUNCTIONS

find_words_in_file($file, @words)

Read file $file on a line by line basis, checking each line for matches on @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).

find_words_in_string($string, @words)

Searches $string on a line by line basis, checking each line for matches on @words.

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.

This returns a list of matches. Each match is a hashref containing the keys line (line number) and word (the matched word).

AUTHOR

Joelle Maslak <jmaslak@antelope.net>

COPYRIGHT AND LICENSE

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.