Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

search and replace confusion

by jonnyfolk (Vicar)
on Nov 08, 2006 at 11:47 UTC ( #582855=perlquestion: print w/ replies, xml ) Need Help??
jonnyfolk has asked for the wisdom of the Perl Monks concerning the following question:

if (lc($Message) =~ /^db /) { print "Content-type:text/html\n\n"; print "c=$Message<br>\n"; $Message = s/^db //; $Message = s/^Db //; $Message = s/^dB //; $Message = s/^DB //; print "m=$Message"; exit; }
output is:
c=Db test4 m=

My aim is to remove the initial Db but in fact everything is removed, it would seem.

Why isn't it doing what I expect?

Comment on search and replace confusion
Select or Download Code
Re: search and replace confusion
by davorg (Chancellor) on Nov 08, 2006 at 11:53 UTC

    Your input contains:

    <!-monthstart--><option value="01">January </option>\n

    Your substitution looks for:

    s/<!--monthstart-->.*<!--monthend-->/MONTHS<br>\n/s;

    Spot the discrepancy :)

    --
    <http://dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

      Aah, thanks very much. More embarrassing is the amount of time I've spent staring at it trying to find my mistake!! :)
Re: search and replace confusion
by reneeb (Chaplain) on Nov 08, 2006 at 11:56 UTC
    You're searching for <!--monthstart, but in $copyindex there is just a <!-monthstart

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://582855]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2014-12-21 06:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (104 votes), past polls