pDale wrote:
> On 7/7/06, $Bill Luebkert <[EMAIL PROTECTED]> wrote:
>>It would probably be more appropriate (if you're going to have malformed
>>paths like the above to go more like:
>>
>>perl -e "$f = qq(C:\\\\test/test.txt); $f =~ s#[\\\/]+#\\#g; print $f"
>>
>>Or just the RE: $file =~ s#[\\\/]+#\\#g;
>
>
> Those extra '\\' sequences are just to get the string past bash, if
> that's what you're refering to (and Perl, since his original "C:\test"
> would actually become [C:<TAB>est].
The path was malformed in that it had \\ rather than just \. I used
cmd.exe on XP, so my commandline was altered from yours. The pertinent
issue is having malformed paths like C:\\dir rather than C:\dir or C:/dir.
The RE above fixes that problem. As far as bash, try:
perl -e '$f = qq(C:\\\\test/test.txt); $f =~ s#[\\\/]+#\\#g; print
qq{$f\n}'
or without the extra \\ and qq{}:
perl -e '$f = "C:\\test/test.txt"; $f =~ s#[\\\/]+#\\#g; print "$f\n"'
It's better to use single quotes on UNIX shells for -e to avoke interpolation.
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs