homepage Welcome to WebmasterWorld Guest from 54.205.144.54
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

    
Help with Perl Script
Advanced Find/Replace CGI Application
CustomFit




msg:434699
 2:39 am on Jan 12, 2004 (gmt 0)

Does anyone have quick pointers on how to write a small Perl script to run on a linux server that'll address some advanced find & replace functions inside document(s) source code?

Here is what I'm trying to do. We'll call the Perl cgi script "engine" in this explanation.

If engine finds a file name ending in *.asp (inside the HTML source code, of course), the engine will rewrite it as *.aspex.

In addition, when engine finds a file name ending in *.asp, it will also adding a predefined line of code ("/newdir/") inside the HTML source code, provided they're all inside an anchor.

Another way to visualize the concept:

Current:

<a href="/index.asp">Link</a>

New:

<a href="/newdir/index.aspex">Dir Link</a>

Thanks in advance!

 

IanKelley




msg:434700
 9:05 am on Jan 12, 2004 (gmt 0)

Look into regular expressions, you'll find endless info if you do a search.

SeanW




msg:434701
 1:49 pm on Jan 12, 2004 (gmt 0)

OTTOMH (untested):

perl -p -i.bak -e 's/(href=\")(.*?asp)\"/$1\/newdir$2ex\"/g' *.asp

Then rename the files yourself (assuming you're using Windows, I think ren *.asp *.aspex will do it.

Sean

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved