Jump to content

Perl/CGI


Recommended Posts

At work I got a lot of search and replace to do from word files to coldfusion files. I was thinking of a way to speed up this process because I got over 500 pages to work with and it takes many days to complete the work. I was thinking of a perl/cgi script that would search and replace many words/codes which could be 75% of the work. I've seen perl/cgi before but how do I install it in IIS 5.1 so I can view them?

Link to post
Share on other sites

Thanks I think I got it figured out.I am trying to search and replace a certain word which is PM 10 for PM<sub>10</sub> and here is the error I got:

CGI ErrorThe specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:Bareword found where operator expected at C:\Inetpub\wwwroot\perl\snr.pl line 8, near "s/PM 10/PM1010
My code:
#!/usr/bin/perlprint "Content-type: text/html\n\n";$string1 = "I love to eat apples all day. I can eat apples every day! Apples are yummy! PM 10";$string1 =~ s/PM 10/PM<sub>10</sub>/gi;print $string1;

It doesn't seem to take html tags in there...

Link to post
Share on other sites

I found a perl coder at work :)I started working with perl to convert some docs and wow you could really save lots of time with this.He told me once someone had to convert lots and lots of excel tables into html tables and it would've taken months but with the script he wrote it took hours. Within a day he was done!!!Anyway I'm working on a script and it's nice.

Link to post
Share on other sites

That's true! I thought of that before, the only problem is php requires a webserver which I don't have at work. That's why I went with Perl, it can run on my computer, no need for a server.

Link to post
Share on other sites
That's true! I thought of that before, the only problem is php requires a webserver which I don't have at work. That's why I went with Perl, it can run on my computer, no need for a server.
Really? Do you run the files through the command line?I learned PERL in college but we always ran them on Apache so I didn't realise you could run them outside a server.
Link to post
Share on other sites

I run them through the command line and programmed it so it takes 2 arguments: first one is the file to convert (word file saved as web page) and second is the file converted (created by Perl). I downloaded activeperl which is offered free here:http://www.activestate.com/Products/ActivePerl/Also need to add the path to perl on your computer once you installed perl. Go in System Properties, Advanced Tab, Environment Variables. You shouldn't have a path for Perl in there so we'll add it. Click New. Enter this:Variable name: PATHVariable value: %PATH%;c:/perl/binThen you start programming. Go in your Command Line and go to your script then type Perl scriptname.pl and this will run your script. I'm still working on the scripting. Search and replace is complicated! You have a bunch of symbols /<*[]?. that mean something to perl but not to me :) . In the long run I'll save lots of time.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...