CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Need a Custom or Prewritten Perl Program?: I need a program that...:
A Script where you input text and it ouputs it how you want ?

 



t MacG
Deleted

Oct 18, 2000, 10:40 AM

Post #1 of 4 (1496 views)
A Script where you input text and it ouputs it how you want ? Can't Post

HI ALL !

I am looking for a script where i can input text, and it will output it in the same format everytime in html format ?

Say i have a text, and i put it in a form, submit it, and it outputs it in the same format that i choose everytime. ?

Way easier than writing an html file everytime no ?

THANKS
Trevor MacG



perlkid
stranger

Oct 17, 2000, 11:12 PM

Post #2 of 4 (1496 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 Frown, I'll write you a little script. Smile

<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).]


perlkid
stranger

Oct 19, 2000, 11:27 PM

Post #3 of 4 (1496 views)
Re: A Script where you input text and it ouputs it how you want ? [In reply to] Can't Post

 
I follow ya,

Could we do the rest of this by mail, because it's 12:20 here, and I have to get up in another 7 hours to go to work (Deadline), I don't want to put it off, but If you email me what you want exactly, I'll mail you back the script so you can set it up really easily.

Thanks Mate,

perlkid

P.S. Also let me know if your on nt or unix based server. Thanks Again


t MacG
Deleted

Oct 20, 2000, 10:00 AM

Post #4 of 4 (1496 views)
Re: A Script where you input text and it ouputs it how you want ? [In reply to] Can't Post

omg..sweet man you are amazing.

Since i have no clue what the script you just wrote does.

I was thinking that mine , when you submit the plain text...creates the html or even better creates a file with the default output settings.
Follow ?

Thanks Amillion

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives