spiritway has asked for the wisdom of the Perl Monks concerning the following question:
Beloved Brethren and Sistren:
I am trying to do what should be a simple substitution, replacing text such as 'http://www.example.com' with a single space. I would have thought that this would do it: $file =~s/http\S+/ /ig;. The goal is to detect 'http' followed by one or more non-whitespace characters. Alas, the substitution doesn't occur, and the unwanted text remains untouched. What am I doing wrong? I seem to be running into a dead end here.
Update: OK, an example of the input follows:
Why pay big bucks? Create your OWN website now! All best software! New software on our site: Illustrator CS - $69.95 # ... Many more lines of this stuff... Visio 2003 Professional - $69.95 Our site: http://polardd.com
This is the input text (one of several files). It is also the output text. I view this using Microsoft Wordpad. I am comforted to find that my code isn't completely off... but of course, I still haven't figured out what the problem actually is... Thanks for the responses, though.
Update 2: I may be a contender for the OT: most egregious programming error, ever award. I was trying to do the substitution on the file name, not the text within the file. I hang my head in shame and will do penance.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: s/// to replace HTTP address with a space
by duff (Parson) on Feb 22, 2006 at 05:55 UTC | |
|
Re: s/// to replace HTTP address with a space
by friedo (Prior) on Feb 22, 2006 at 05:55 UTC | |
|
Re: s/// to replace HTTP address with a space
by strat (Canon) on Feb 22, 2006 at 09:08 UTC | |
|
Re: s/// to replace HTTP address with a space
by davidrw (Prior) on Feb 22, 2006 at 14:10 UTC |