|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
Hello..
Thank You very much dsb. I hope Perl has got no special functions to do that. Thanks again... Dups |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > backslash to forward slash conversion |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|