perl find&replace&find replacive

January 20, 2009 at 01:32:23
Specs: windows xp/2k/nt, -
Hello, total newbie here.

I have to make perl that changes a certain url in every .htm/.html -document that it can find in a directory tree.

The urls that need to be replaced are in form:

<a href="http://first/second/link?open&0L000002-001">

and they need to be replaced like so:

<a href='http://first/lah/dih/dah/0L000002_001.dwg'>

Only the "0L000002-001" -part (which can be anything between 0L000001-001 and 9L999999-099) can be used as the "search term" to localize the right url from the list.

This could easily be done with just notepad, but the subfolders in the right urls are not always the same.

I have a separate .txt-file that contains only urls that can be used as the substitute for the "link?open..."-url, as long as the right one is found. Here's a few for example




I'm guessing this gets too complicated for oneliner since such regexp need to be used?
perl -p -i -e 's/old/new/g' `find ./ -name *.htm$`


See More: perl find&replace&find replacive

Report •

January 20, 2009 at 04:36:30
This method cannot be used, since I found out the list of urls is going to have over 100,000 lines.

Sorry for wasting forum space!

Report •
Related Solutions

Ask Question