- or download this
my(@lines) = <MYINPUTFILE>; # read file into list
- or download this
# match the string "foo" on "word boundaries"
my @line_numers = grep { $lines[$_] =~ /\bfoo\b/ } 0 .. $#lines;
- or download this
# match lines containing the single word "foo",
# ignoring whitespace
my @line_numers = grep { $lines[$_] =~ /^\s*foo\s*$/ } 0 .. $#lines;