#!/usr/bin/perl use CGI; use strict; my $q = CGI->new; my $string = $q->param('content'); # the posted string. $string =~ s/\r?\n$//s; # remove trailing CRLF if ($string =~ /foo/) { # decide what to do depending on input print $q->redirect('http://host.tdl/some/other/uri'); } else { print $q->header,$q->start_html; if($string) { # print "

You posted: $string\n"; # <-- bad # what oxone said below - avoid XSS attacs print "

You posted: ",$q->escapeHTML($string),"\n"; # <-- better } else { print < EOH } print $q->end_html; }