Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 28th, 2001, 12:50 AM
Dups Dups is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 30 Dups User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
backslash to forward slash conversion

Hello there ....

At present I am trying to make my application in perl to work
on both linux and Windows NT.
In order to get the current working directory, in Linux I used a method which did some manipulation on the REQUEST_URI environment variable and returns the current working directory.

In Windows NT I didn't find such an environment variable .
Instead I found a PATH_INFO variable. But there the slashes
were in the reverse direction. I would like to know whether
Perl has got any function to handle the conversion of backslashes
to forward slashes.

Thanks in advance...
Dups

Reply With Quote
  #2  
Old June 28th, 2001, 11:45 AM
dsb dsb is offline
PerlGuy
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2001
Posts: 714 dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 15 h 44 m 20 sec
Reputation Power: 36
Send a message via AIM to dsb
Talking

You could use a simple substitution regular expression:
Code:
$var =~ s%\%/%;


Depending on your code, you made need to employ certain modifiers. The above code would be could for say switching one Windows directory path at a time.

If you are trying to get them all in one shot with some kind of loop, you could simply use the 'g' modifier in a loop. The 'g' modifier would catch all occurences of '\', or whatever string is being matched.
Code:
while ( $data =~ m%\% ) {
     $data =~ s%\%/%g;
}


Hope that helps.
__________________
- dsb -
Perl Guy

Reply With Quote
  #3  
Old June 28th, 2001, 11:55 PM
Dups Dups is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 30 Dups User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Hello..

Thank You very much dsb.
I hope Perl has got no special functions to do that.

Thanks again...
Dups

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > backslash to forward slash conversion


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway