For one portion of the forum, I want to automatically adjust a subject line if it matches another one. (Kind of like how this forum can have multiple threads with the same title.) I can't quite figure out what I'm doing wrong.
Here's what I have right now:
Code: Select all
#!/usr/bin/perl
print "Content-type: text/html\n\n";
$string = "This is a test";
@subjects = ("This is a test","This is a test (2)");
$postCount = 1;
# This is a test
print "$string<br />";
while (grep /$string/, @subjects) {
$postCount++;
if ($string !~ /\(\d+\)$/) {
$string = $string . " ($postCount)";
#Skipped
print "Skipped!<br />";
}
$string =~ s/\d+\)$/$postCount\)/;
#This is a test (2)
print "$string<br />";
}
#This is a test (3)
print $string;
exit;
The output I get from this script is:
Code: Select all
This is a test
Skipped!
This is a test (2)
This is a test (2)
This is the only thing holding me back. The rest of the forum script is nearly finished. I've tried all sorts of things including different loops and conditions. This is the closest I've gotten. I know it's something apparent that I'm not seeing.