Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Nov 2001
Posts: 436
Member
Member
Offline
Joined: Nov 2001
Posts: 436
I need to know how to find something in a CGI/Perl document and replace it with something else. It's for an interactive story I have, I want people to be able to make a return and have it go down to the next line... so, basically, how do I find n and replace it with < br > ? BUT... here's the tricky part...

The CGI file is a totally different file than where the story shows up. The Add Paragraph form in Story.shtml (the file where the story shows up) goes to story.cgi and tells it to add this paragraph, and then it sends it back and adds it. So, how would I find n in the form where people type their paragraph in story.shtml and replace it with < br >, from story.cgi?

Thanks!

Sponsored Links
Joined: Jan 2000
Posts: 5,073
Admin Emeritus
Admin Emeritus
Joined: Jan 2000
Posts: 5,073
CGI is a protocal.

Perl is the scripting language.

Please use Perl when refering to a Perl script that functions as a CGI.

Moving this to the Perl forum.


UBB.classic: Love it or hate it, it was mine.
Joined: Mar 2001
Posts: 7,394
LK Offline
Admin / Code Breaker
Admin / Code Breaker
Offline
Joined: Mar 2001
Posts: 7,394
Right before you send it back, add:

$variable =~ s/n/
/ig;

(change $variable to the variable's name)

Joined: Nov 2001
Posts: 436
Member
Member
Offline
Joined: Nov 2001
Posts: 436
Eep, sorry about posting in the wrong forum.

And, which variable should I replace it with, and where exactly should I put that?

Joined: Jul 2001
Posts: 108
Member
Member
Offline
Joined: Jul 2001
Posts: 108
the $variable should be whatever variable the line of text you are getting from the user is. And should come after you get that line of text from the user.

Sponsored Links
Joined: Nov 2001
Posts: 436
Member
Member
Offline
Joined: Nov 2001
Posts: 436
Hmmm... This is what I have:
[code][/code]

Is that how/where it should be? (look three lines from the bottom, that's the code you gave me)

[ 12-24-2001 05:10 PM: Message edited by: BloggerMan ]

Joined: Nov 2001
Posts: 436
Member
Member
Offline
Joined: Nov 2001
Posts: 436
er.... sorry for stretching the whole page

If anyone wants me to, I can send them the whole cgi file so they can look at it for me and tell me what to put?

Joined: Jul 2001
Posts: 108
Member
Member
Offline
Joined: Jul 2001
Posts: 108
uh, i would do something more like this...

[code][/code]

as far as what you doing, it looks like your adding the code in, then replacing the n with
but you should replace first, then add.

Joined: Nov 2001
Posts: 436
Member
Member
Offline
Joined: Nov 2001
Posts: 436
ok, now I have:
[code][/code]

I got a 500 internal server error.

[ 12-24-2001 11:23 PM: Message edited by: BloggerMan ]

Joined: Jul 2001
Posts: 108
Member
Member
Offline
Joined: Jul 2001
Posts: 108
how are you getting this info from the form? Are you useing the use::CGI modedule or that long ugly code that does sorta the same thing?

Sponsored Links
Joined: Jul 2001
Posts: 108
Member
Member
Offline
Joined: Jul 2001
Posts: 108
oh and BTW, it seems like to me, you are formating all the stuff then putting it into the story.cgi file, so, pray tell, why are you putting it into a cgi file? why not just put it into a TXT file and call it via SSI? That seems to me to be the easiest way...

Joined: Nov 2001
Posts: 436
Member
Member
Offline
Joined: Nov 2001
Posts: 436
What?
If you want to take a look at what the CGI script is doing, go here: http://www.thegrabbag.net/story.shtml
Let me try to restate the question...
The CGI script is telling the form what to do. The CGI script writes what the person typed to story.shtml, and I'm wondering how to make it so that whenever the person makes a Return, I want to replace it with an HTML break,
, because when the script writes the text to story.shtml, it just writes it with the returns, and only pre-formatted text will recognize returns as breaks. So I want to replace all returns with
, so that they show up as breaks.

It's the same thing with UBB, when you hit the Enter key on your keyboard, the UBB script replaces that with a
tag.

How do I do that?

Joined: Jul 2001
Posts: 108
Member
Member
Offline
Joined: Jul 2001
Posts: 108
Code
[/code]

Is that how/where it should be? (look three lines from the bottom, that's the code you gave me)

<font color="#000000" size="1">[ 12-24-2001 05:10 PM: Message edited by: BloggerMan ]</font>[/b]</font><hr /></blockquote><font size="2" face="Verdana, Helvetica, sans-serif">

Try this then

[code]

Joined: Nov 2001
Posts: 436
Member
Member
Offline
Joined: Nov 2001
Posts: 436
no good
Is there a way to find n in a certain form (in this case, "story"), and then replace the stuff? Except, the form is in story.shtml.

Joined: Jul 2001
Posts: 108
Member
Member
Offline
Joined: Jul 2001
Posts: 108
Okay, i don't know what to tell you then, that is the exact line of code to replace the n you just have to put it in the right place.

Joined: Nov 2001
Posts: 436
Member
Member
Offline
Joined: Nov 2001
Posts: 436
ok, thanks anyways.

Joined: Feb 2001
Posts: 18
Junior Member
Junior Member
Offline
Joined: Feb 2001
Posts: 18
Change:

Code
[/code]

to

[code]

$FORM{'story'} is the variable that contains the story the user wrote, thus you want that variable to be pattern matched as indicated above to transform linebreaks into HTML breaks.


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
Posts: 70
Joined: January 2007
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20240430)