in reply to html into an array

If I now read this file into an array and then try to grep the array index, it just doesn't work.
Of course it works, it just doesn't do what you think it should do. Since we don't know what code you've got, what you want it to do, or what it currently does, you're probably not going to get very helpful replies until you provide that information.

See also How do I post a question effectively?.

Update: please mark your updates (like I did this one) and use <code> .. </code> tags to mark your code. it makes it a lot easier to read (and type). See also writeup formatting tips.

Anyway, I'm assuming you've omitted a few pieces in that code snippet that are actually there in the real code (like the part where you write to "clean_text").

Note that

my(@lines) = <MYINPUTFILE>; # read file into list
Puts the complete lines in @lines. That includes the newline character "\n". Since every line (except possibly the last one) ends with "\n" and $search does not, your match is not going to work. (See also chomp)

I also note that it's very likely the lines have other whitespace in them. It's probably easier to match using a regular expression:

# match the string "foo" on "word boundaries" my @line_numers = grep { $lines[$_] =~ /\bfoo\b/ } 0 .. $#lines;
or
# match lines containing the single word "foo", # ignoring whitespace my @line_numers = grep { $lines[$_] =~ /^\s*foo\s*$/ } 0 .. $#lines;
updated: bug fixed for the grep() expression.