vchris 3 Posted September 18, 2006 Report 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? Quote Link to post Share on other sites
justsomeguy 1,135 Posted September 18, 2006 Report Share Posted September 18, 2006 Start here:http://activestate.com/Products/ActivePerl/?mp=1 Quote Link to post Share on other sites
vchris 3 Posted September 18, 2006 Author Report 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... Quote Link to post Share on other sites
justsomeguy 1,135 Posted September 18, 2006 Report 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; Quote Link to post Share on other sites
vchris 3 Posted September 19, 2006 Author Report Share Posted September 19, 2006 Now I only have a blank page. Quote Link to post Share on other sites
justsomeguy 1,135 Posted September 19, 2006 Report Share Posted September 19, 2006 Hmm, being not the Perl guru that I am (not), I probably won't be much more help. Quote Link to post Share on other sites
vchris 3 Posted September 21, 2006 Author Report 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. Quote Link to post Share on other sites
aspnetguy 30 Posted September 21, 2006 Report Share Posted September 21, 2006 Anything you can do with PERL you can probably do with PHP you know Quote Link to post Share on other sites
vchris 3 Posted September 21, 2006 Author Report 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. Quote Link to post Share on other sites
aspnetguy 30 Posted September 21, 2006 Report 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. Quote Link to post Share on other sites
vchris 3 Posted September 21, 2006 Author Report 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. Quote Link to post Share on other sites
aspnetguy 30 Posted September 21, 2006 Report Share Posted September 21, 2006 those symbols are Regualr Expressions, lol, they are a pain in the neck to say the least. Quote Link to post Share on other sites
vchris 3 Posted September 21, 2006 Author Report Share Posted September 21, 2006 Regular expressions maybe for regular perl programmers but chinese for me! Quote Link to post Share on other sites
Little Goat 0 Posted September 22, 2006 Report Share Posted September 22, 2006 actually, php can be run on the command line too. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.