#!/usr/bin/perl -w use Tie::File; use strict; ### ### This is a complete, self-contained dummy script to ### test the insert functionality of this sub... ### ########################################################################## ### ### These vars should be changed to demonstrate different behaviours ### my $thread = "208"; # is the thread identifier my $msg_id = "211"; # is this message's unique number my $parent = "208_208"; # is the message_id of the parent post ## To create new top-level post set $thread=$msg_id, $parent is ununsed ## and should be undef ## All replies to given top-level post should carry same $thread value, ## whereas $msg_id is incremented ## Set $parent to: ($thread . "_" . $msg_id) to make a reply to the ## post which carries that message_id string in the html comment ## $msg_id should be unique for each post ($msg_id++) ## $thread should be unique for each thread ######################################################################### ### ### These vars are (relatively) static ### my @threads; # the array we will use my $main_threads_file = "threads.html"; # the threads file we will work on my $link = "
  • dummy link to message $thread - $msg_id"; ### Update the main threads file tie @threads, 'Tie::File', $main_threads_file or syslog('err', "update_threads couldn't open file: $main_threads_file"); if ($thread == $msg_id) { # put it right at the top, it's a new thread unshift @threads, $link; } else { for my $i (0 .. $#threads) { if ($threads[$i] =~ $parent) { if ($threads[$i+1] eq "