###### listing 1 ###### #!/home/merlyn/bin/perl -Tw use strict; $|++; my $GO_LOG = "/home/merlyn/Web/golog"; my $result = eval { die unless defined (my $res = $ENV{PATH_INFO}); die unless $res =~ s/^\///; my $query = $ENV{QUERY_STRING}; if (defined $query and length $query) { $res .= "?$query"; } $res; }; if ($@) { print "Status: 404 Not Found\n\n"; exit 0; } print "Location: $result\n\n"; my $pid = fork; $pid = 0 unless defined $pid; # be the kid if fork failed exit 0 if $pid; ## child... close(STDOUT); open GOLOG, ">>$GO_LOG" or die "Cannot open $GO_LOG: $!"; flock(GOLOG,2); # wait for exclusive seek GOLOG, 0, 2; # seek to end, refresh buffers print GOLOG join("\t", scalar localtime, $result, ($ENV{HTTP_REFERER} || "[unknown]")), "\n"; close GOLOG; ###### listing 2 ###### #!/home/merlyn/bin/perl -w use strict; $|++; use File::Find; unless (@ARGV) { find sub { push @ARGV, $File::Find::name if /\.html/; }, "/home/merlyn/Html/"; } undef $/; $^I = "~"; while (<>) { s{(href="(.*?)")}{ my ($old,$url,$new) = ($1,$2); if ($url =~ /^http:(?!.*cgi\/go)/) { $new = qq{href="/cgi/go/$url"}; print STDOUT "$ARGV: changing $old to $new\n"; } else { $new = $old; } $new; }egi; print if defined $^I; }