vchris Posted September 18, 2006 Share Posted September 18, 2006 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 comment Share on other sites More sharing options...
justsomeguy Posted September 18, 2006 Share Posted September 18, 2006 Start here:http://activestate.com/Products/ActivePerl/?mp=1 Link to comment Share on other sites More sharing options...
vchris Posted September 18, 2006 Author Share Posted September 18, 2006 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/PM1010My 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 comment Share on other sites More sharing options...
justsomeguy Posted September 18, 2006 Share Posted September 18, 2006 It sees the third / and thinks you are ending the pattern. You need to escape it:$string1 =~ s/PM 10/PM<sub>10<\/sub>/gi; Link to comment Share on other sites More sharing options...
vchris Posted September 19, 2006 Author Share Posted September 19, 2006 Now I only have a blank page. Link to comment Share on other sites More sharing options...
justsomeguy Posted September 19, 2006 Share Posted September 19, 2006 Hmm, being not the Perl guru that I am (not), I probably won't be much more help. Link to comment Share on other sites More sharing options...
vchris Posted September 21, 2006 Author Share Posted September 21, 2006 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 comment Share on other sites More sharing options...
aspnetguy Posted September 21, 2006 Share Posted September 21, 2006 Anything you can do with PERL you can probably do with PHP you know Link to comment Share on other sites More sharing options...
vchris Posted September 21, 2006 Author Share Posted September 21, 2006 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 comment Share on other sites More sharing options...
aspnetguy Posted September 21, 2006 Share Posted September 21, 2006 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 comment Share on other sites More sharing options...
vchris Posted September 21, 2006 Author Share Posted September 21, 2006 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 comment Share on other sites More sharing options...
aspnetguy Posted September 21, 2006 Share Posted September 21, 2006 those symbols are Regualr Expressions, lol, they are a pain in the neck to say the least. Link to comment Share on other sites More sharing options...
vchris Posted September 21, 2006 Author Share Posted September 21, 2006 Regular expressions maybe for regular perl programmers but chinese for me! Link to comment Share on other sites More sharing options...
Little Goat Posted September 22, 2006 Share Posted September 22, 2006 actually, php can be run on the command line too. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now