Where is "split on '.'" documented?

M

Michele Dondi

so it seems that stings other than ' ' are automatically converted to
regexen in the "obvious" (or "simplest"?[*]) way.

That's correct.
[*] It would be more obvious IMHO to convert $string to /\Q$string/.

That's not going to happen, since that would break a LOT of existing ^^^^^^^^^^^^^^^^^
code.
^^^^

This is a good reason, but personally I'd find it very perlish to
allow for a diversified behaviour, not necessarily the one (I)
suggested above: typically whenever Perl admits for a variant on some
basic syntax, it will do something different, and usually *what I
mean*(TM)!
Some time ago I proposed to emit a warning when the first argument to
split is a plain string, but there are good arguments against it as
well. (and moreover I haven't produced a good patch for it either;)

Then the current documentation, even if *not* incorrect or misleading
(as someone else suggested), could be updated to mention that
(generic) plain strings can be used and explain how they will be
treated.

In particular

is that enough to explain PATTERN? [snip]
what more would you want? the first argument to split is a PATTERN. also
known as a regex, regular expression

But your claim underlined above, if true, and I do not have any reason
to doubt it is, contradicts him to some extent. Only to some extent
because he speaks of "pattern" or "regex" and not of "m// operator";
OTOH 'perldoc -f split' only mentions "/PATTERN/"...


Michele
 
E

Eric Amick

Then the current documentation, even if *not* incorrect or misleading
(as someone else suggested), could be updated to mention that
(generic) plain strings can be used and explain how they will be
treated.

The following already appears in the documentation:

The pattern /PATTERN/ may be replaced with an expression to specify
patterns that vary at runtime.

Perhaps it could be modified to point out that any kind of pattern can
be done that way.
 
J

J.B. Moreno

Michele Dondi said:
I just can't grasp what you mean exactly. I think the key to
understand it is in the expression "any kind of pattern", but then can
you expand the concept please?

Anytime you are using a pattern match, instead of PATTERN you could have
$p='PATTERN'; and use $p instead.

For example, $str =~ s/question/answer/;

could be written as $q='question'; $str=~ s/$q/answer/;
 
M

Michele Dondi

The following already appears in the documentation:

The pattern /PATTERN/ may be replaced with an expression to specify
patterns that vary at runtime.

Perhaps it could be modified to point out that any kind of pattern can
be done that way.

I just can't grasp what you mean exactly. I think the key to
understand it is in the expression "any kind of pattern", but then can
you expand the concept please?


Michele
 
E

Eric Amick

I just can't grasp what you mean exactly. I think the key to
understand it is in the expression "any kind of pattern", but then can
you expand the concept please?

I mean that mentioning patterns that vary at runtime makes it sound as
if that is the only time using an expression is allowed, which simply
isn't true.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,609
Members
45,253
Latest member
BlytheFant

Latest Threads

Top