Richard A. Wells wrote:
> On UNIX you have to escape the whitespace, e.g.
>
> /this path/has spaces
>
> would become
>
> /this\ path/has\ spaces
>
> The expression
>
> $path_elem =~ s{(\s)}{\\$1}gio;
The /io is not needed/wanted.
> should do the trick.
>
> Note that I used {} delimiters (i.e. s{}{}) to make it clearer, since
> the data itself contains /s and someone might get confused that a / was
> part of the match or substitution, rather than a delimiter. But you
> still could use s///, if you prefer. Also, \\ is necessary in the
> substituion value, since \ itself is a metacharacter in a regex.
I think it's easier to read this:
my $win32 = $^O =~ /Win32/i;
my $path_elem = $ENV{CLEARCASE_PN};
$path_elem =~ s/ /\ /g if not $win32;
PS: Top-posting is something we try to avoid in these lists.
>> Hi All,
>>
>> I am meeting a problem on a regular expression.
>>
>> My code is like:
>>
>> $path_elem = "$ENV{'CLEARCASE_PN'}";
>>
>> The return value of $path_elem is either
>>
>> $path_elem = /ccstore/test/test.pl
>>
>> Or $path_elem = /ccstore/test 1/test 1.pl # there is a space in the
>> path name including the file name too
>>
>> There is no rule whether there is a space in the path name or not. How
>> can I handle it in regular expression, because when I pass the value
>> $path_elem to a function, if there is a space in the path name, it will
>> treat it 2 file path name, instead of one.
>>
>> I used the following code
>>
>> $path_elem = "\"$ENV{'CLEARCASE_PN'}\"";
>> It works fine for windows, but does not works fine on unix.
>>
>> I really appriciate your great help.
--
,-/- __ _ _ $Bill Luebkert Mailto:[EMAIL PROTECTED]
(_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED]
/ ) /--< o // // Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_ http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs