go ahead... be a heretic | |
PerlMonks |
Re: Re: spaces in filenamesby dvergin (Monsignor) |
on Feb 03, 2003 at 03:09 UTC ( [id://232119]=note: print w/replies, xml ) | Need Help?? |
You say: You should pass a pattern as its first argument, but instead you're passing a scalar. Yes, split does expect a pattern. But no, it does not have to be delimited with forward slashes. In fact, Perl doesn't even require delimiters here. A scalar value in a variable will be interpreted as a pattern also. Either of the following cases works fine... perldoc -f split says "The pattern "/PATTERN/" may be replaced with an expression to specify patterns that vary at run-time." but then confuses things by going on with, "(To do runtime compilation only once, use "/$variable/o".)" which makes it look like you still need the slashes. (Which you do if you want to add the '/o'.) Camel 3, page 796, is more clear on this point when it says "if you supply a string instead of a regular expression, it will be interpreted as a regular expression anyway."
------------------------------------------------------------
In Section
Seekers of Perl Wisdom
|
|