K
Klaus
Hello everybody,
I need the wisdom of the perl community.
I have a perl program that uses the split function as follows:
my ($tag, $value) = split(":\s*", $_, 2);
I want to split on ':', followed by optional whitespaces.
When I run the program, I get a warning
Unrecognized escape \s passed through at test.pl line 228.
and the split is performed on the string ":\s", and NOT on the regular
expression /:\s+/.
I was thinking that perl (at least perl 5.8) interprets the first
parameter of the split function always as a regular expression, even
if it is a simple string, i.e. if I say:
split(":\s*", $_, 2)
then perl interprets this automatically and without warning into
split(/:\s*/, $_, 2)
Is my thinking correct ? under perl 5.8 ? under perl 5.10 ?
Unfortunately I have no perl 5.8 available to test split(":\s*", $_,
2); under perl 5.8
I am using perl -v
This is perl, v5.10.1 built for MSWin32-x64-multi-thread
I need the wisdom of the perl community.
I have a perl program that uses the split function as follows:
my ($tag, $value) = split(":\s*", $_, 2);
I want to split on ':', followed by optional whitespaces.
When I run the program, I get a warning
Unrecognized escape \s passed through at test.pl line 228.
and the split is performed on the string ":\s", and NOT on the regular
expression /:\s+/.
I was thinking that perl (at least perl 5.8) interprets the first
parameter of the split function always as a regular expression, even
if it is a simple string, i.e. if I say:
split(":\s*", $_, 2)
then perl interprets this automatically and without warning into
split(/:\s*/, $_, 2)
Is my thinking correct ? under perl 5.8 ? under perl 5.10 ?
Unfortunately I have no perl 5.8 available to test split(":\s*", $_,
2); under perl 5.8
I am using perl -v
This is perl, v5.10.1 built for MSWin32-x64-multi-thread