Help for this page

Select Code to Download


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