Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with string manipulation

Status
Not open for further replies.

kirk124

Programmer
Apr 15, 2003
26
US
Hi:
I am having problem turning the string "c:\/data/CDS/BCS3Lite" into "c:\\data\\CDS\BCS3Lite".

Someone suggest "s#[/\\]#\\\\#g" but this caused the string to become "c:\\\\data\\CDS\\BCS3Lite". Not what I wanted.

--thanks

 
Kirk, a legitimate directory in Perl under Windoze is
c://data/CDS/BCS3Lite

HTH
Paul
 
PaulTEG, can't use forward slashes to seperate directories in system calls such as exec(), system() and backticks. And "c://blah" (with 2 slashes) is not a legitimate windows directory.
 
I think Paul might have meant to say:

Kirk, a legitimate directory in Perl under Windoze is
/data/CDS/BCS3Lite

Perl internals will handle the / \ issue. However, this only works for your base volume. If you wanted to work with the D: volume and your base is C: then you will need to coerce the slashes into the correct format.

The TopMach's solution should be the one to go for.

Barbie
Leader of Birmingham Perl Mongers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top