|
-
Dec 31st, 2005, 08:21 PM
#1
Thread Starter
Frenzied Member
Reading 2 files
Here is my problem, I have 2 textfiles, say file1.txt and file2.txt
file1.txt
Date: Dec 25, 2005
Title: Hey
Content: blah
file2.txt
Title: Hey
Comment: something
I tried to code up to read those two files, basically, it loops through the array, and if the Title from file1 matches the word in Title from file2, then print the comment. Below is the code:
foreach $myword1 (@lines) {
chomp($myword1);
$myword1 =~ m/^\s*title: /i;
foreach $myword2 (@comments){
chomp($myword2);
#chomp($myword3 = $_);
$myword2 =~ m/^\s*title: /i;
foreach $myword3 (@comments){
chomp($myword3);
if(($myword1 eq $myword2) && ($myword3 =~ m/^\s*comment: /i) {
print $myword3 . "<p>";
}
}
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|