XML technologies / Regular expressions / Perl / The split operator / Special forms of the regex operand for split

(Excerpt from "Regular expressions" by Jeffrey E. F. Friedl)

Usually, the match operand of split is a regex literal or object, just as for the match operator. There are special cases, however:

 

split has no side effects

The match operand of split often resembles the match operator, but it is not one and has no side effects. The regex in split does not affect the default regex used by later matches or substitutions. Variables $&, $', $1 and so on are not set and remain untouched by split. Regarding side effects, split is isolated from the rest of the program. One exception concerns an obsolete and discouraged feature still implemented: when split is used in scalar or void context, its result elements are written to array @_, which also holds subroutine arguments. Avoid accidentally using split in scalar or void context. With warnings enabled by -w or use warnings , Perl warns about it.

  

 

 

 

German edition copyright © 2008 by O’Reilly Verlag GmbH & Co. KG
You may print the online version for private use.
Otherwise, this chapter from "Reguläre Ausdrücke" is subject to the same terms as the bound edition: the work and all its parts are protected by copyright. All rights reserved, including reproduction, translation, microfilming, storage and processing in electronic systems.

O’Reilly Verlag GmbH & Co. KG, Balthasarstr. 81, 50670 Köln

back to top