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.


In reply to s/// to replace HTTP address with a space by spiritway

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.