Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: quite weird regexp

by cadfael (Friar)
on Nov 30, 2000 at 20:16 UTC ( [id://44159]=note: print w/replies, xml ) Need Help??


in reply to quite weird regexp

There is a real good reason why there is an option for changing the delimiter in pattern substitution. Witness the following code I used to alter URLS that needed to appear in a text field in a flatfile database:
while(<>){ #take input from STDIN s/\/\//\\\/\\\//g; print STDOUT; }
Why? Because the designers of this flatfile database decreed that "//" would be interpreted as the beginning of a comment, thus causing everything after "http://" to be lost. So I escaped those particular forward slashes using s///; It looks atrocious, but it did the job.

Using an alternate delimiter wouldn't eliminate the need for all the forward and back slashes, but at least it would show me (or another trying to decipher the above atrocity) where the expression was delimited.

-----
"Computeri non cogitant, ergo non sunt"

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://44159]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2024-04-18 06:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found