I have a perl script that reads an html file and puts it's contents into an array. Next it finds all of the lines that match a certain pattern and puts those lines into their own array. Finally it counts the number of items in that array and gives me the value that I am looking for. The code I use for that is as at the bottom. I am trying to determine how I need to go about this to do it in php. Would preg match be the correct function to use in the foreach statement, and how should I open/read the file and put its contents into an array?
Forum Total Number Add On
open(FORUM,"$forum_basedir/$mesgfile");
@forum_total = <FORUM>;
close(FORUM);
foreach $forum_line (@forum_total) { if ($forum_line =~ /<!--top: (.)--><li><a href=$mesgdir\/\1.$ext>.<\/a> by .\s+<font size=-1 color=#CE0000>(.)<\/font>/) {
@forum_total_number = (@forum_total_number, $forum_line);
}
}
$forum_total_number = @forum_total_number;