Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Replace text - includes tilde sign?

by dwm042 (Priest)
on Sep 21, 2007 at 11:39 UTC ( [id://640339]=note: print w/replies, xml ) Need Help??


in reply to Replace text - includes tilde sign?

As far as I can see, the problem isn't the tilde so much as the unescaped character just before the tilde. It's the same as your separator. If you use a slightly different syntax for the search and replace, you can do the transformation without issue.

~/perl/monks$ cat test_tilde.pl #!/usr/bin/perl use warnings; use strict; my $test = "This is a test of a replacement string, really (example.com) and truly."; print $test, "\n"; $test =~ s|example\.com|12\.23\.56\.78\/\~example|g; print $test, "\n";
The output is:

~/perl/monks$ ./test_tilde.pl This is a test of a replacement string, really (example.com) and truly. This is a test of a replacement string, really (12.23.56.78/~example) and truly.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-04-23 07:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found