CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
How do I replace a / with a \ in a string.

 



jbs
Deleted

Jun 6, 2000, 10:05 PM

Post #1 of 2 (242 views)
How do I replace a / with a \ in a string. Can't Post

I'm finding a list of files using file::Find. I havent implemented this algor. yet, but here is the trouble I'm having in my mock mini-script.

#THIS PROGRAM REPLACES "a" INTO "b"
#THIS PROGRAM REPLACES "/" INTO "\"

@ll=("a/","avasdf/","ag///");

#this is the loop that does the changing

foreach (@ll){
s/a/b/g;
s/'/'/'\'/g;
print "$_ \n";


}
I cant seem to make it change the blackslash. I know this is easy, I just can seem to figure it out!


drone01
Deleted

Jun 6, 2000, 10:23 PM

Post #2 of 2 (242 views)
Re: How do I replace a / with a \ in a string. [In reply to] Can't Post

s/\//\\/g; #replace all "/" with "\"

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives