
perlkid
stranger
Oct 17, 2000, 11:12 PM
Post #2 of 4
(1237 views)
|
|
Re: A Script where you input text and it ouputs it how you want ?
[In reply to]
|
Can't Post
|
|
Since my server is down , I'll write you a little script. <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> #!/usr/bin/perl ############################################# sub parse_form { my (@pairs, %in); my ($buffer, $pair, $name, $value); if ($ENV{'REQUEST_METHOD'} eq 'GET') { @pairs = split(/&/, $ENV{'QUERY_STRING'}); } elsif ($ENV{'REQUEST_METHOD'} eq 'POST') { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); } else { &cgierr('You cant run this script from telnet/shell.'); } PAIR: foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $name =~ tr/+/ /; $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; ($value eq "---") and next PAIR; exists $in{$name} ? ($in{$name} .= "~~$value") : ($in{$name} = $value); } return %in; } ############################################# %in =&parse_form; print "Content-type: text/html\n\n"; # change this to your path to an html template # be sure to put the tag !text! where you # want the text to be placed in the html $template = "/home/path/to/template/html"; ############################################# open(template, "<$template"); @all=<template>; close(template); $file="@all"; $file =~ s/!text!/$in{'text'}/i; print "$file"; exit; </pre><HR></BLOCKQUOTE> That was short, Is ther anything else you want it to do? Do you need it to print to a file at all? perlkid tony@seeki.com [This message has been edited by perlkid (edited 10-18-2000).]
|