michael.kitchen has asked for the wisdom of the Perl Monks concerning the following question:
Edited on 8/20, 2017
I really am a novice at this. I learned some basic CGI programming using Perl 5 from a book. I needs have always been pretty simple and so I have not signed up for any in depth training. Sorry for only supplying one line of code in my original post. I will supply more code in this post. Before doing so I would like to explain a little more about what I am doing in hopes that the additional information will help.
First of all I am creating a fansite for a game that I play. I am copying information from a wiki site and putting it into my makeCREATURE.cgi that saves pre-formatted data to a file that will be used by my creatureDETAIL.cgi script when visitors want to view details of a creature from the game. I use Firefox to view wiki information and perform my copy. I then paste it into Chrome (because that is where my bookmarks are for my stuff). I came up with the necessary substitution statements to take care of everything that needed to be eliminated or html tags added, etc. I just could not come up with the substitution for the multiplication sign. Viewing source of wiki page shows that × is being used for the multiplication sign. I created a small program (lootALTERATION.cgi) to handle all the substitutions I could figure out how to do. I then remove the multiplication signs manually and copy/paste into my makeCREATURE.cgi script.
An example of the information I am copying/pasting is: 0-100× Gold Coin
I will supply the entire code from lootALTERATION.cgi:
I'm sure there are better and more efficient ways of doing things. Not against learning new ways, but this way works and it is what I know. Please be kind. :)#!/usr/bin/perl use CGI qw/:standard/; push(@INC, "/cgi-bin"); require("cgi-lib.pl"); &ReadParse(*input); @loot = $input{'loot'}; print "Content-type: text/html\n\n"; print qq{ <HTML> <HEAD> <TITLE>Loot Alteration</TITLE> </HEAD> <BODY> <form method=post action="../cgi-bin/lootALTERATION.cgi"> <table border=2 width=100%> }; print "<tr>\n"; print "<td>Loot</td>\n"; print "<td>Copy / Paste Paragraph.<br><textarea name=loot cols=70 rows +=10>"; for (@loot) {s/ //g}; for (@loot) {s/×//g}; for (@loot) {s/ \(semi-rare\)//g}; for (@loot) {s/ \(rare\)//g}; for (@loot) {s/ \(very rare\)//g}; for (@loot) {s/ \(extremely rare\)//g}; for (@loot) {s/\R/<br>/g}; print "@loot"; print "</textarea></td>\n"; print "</tr>\n"; print qq{ <tr> <td><input type=submit></td> <td><input type=reset></td> </tr> </table> </form> </BODY> </HTML> };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: replace multiplication symbol (×)
by kcott (Archbishop) on Aug 20, 2017 at 08:32 UTC | |
|
Re: replace multiplication symbol (×)
by Corion (Patriarch) on Aug 20, 2017 at 07:22 UTC | |
|
Re: replace multiplication symbol (×)
by Laurent_R (Canon) on Aug 20, 2017 at 08:34 UTC | |
|
Re: replace multiplication symbol (×)
by huck (Prior) on Aug 20, 2017 at 05:21 UTC | |
by LanX (Saint) on Aug 20, 2017 at 09:50 UTC |