oesi50: Betriebsblindheit :-(

Beitrag lesen

Hallo Christoph,

die funktion split teilt deinen String so auf
x1|x2|x3||
('x1','x2,'x3',undef)

oh. Das ist mir völlig neu, und das kann ich auch nicht nachvollziehen. Nach meiner Lesart ist "split" keine Funktion, sondern eine Perl-Anweisung, die lediglich zwei Parameter übergeben bekommt. Die Backslashes sind "Maskierungen"

Auszug aus der Perldoku (Kapitel perlfunc):

split /PATTERN/,EXPR,LIMIT

split /PATTERN/,EXPR

split /PATTERN/

split

Splits a string into a list of strings and returns that list. By default, empty leading fields are preserved, and empty trailing ones are deleted.
If not in list context, returns the number of fields found and splits into the @_ array. (In list context, you can force the split into @_ by using ?? as the pattern delimiters, but it still returns the list value.) The use of implicit split to @_ is deprecated, however, because it clobbers your subroutine arguments.

If EXPR is omitted, splits the $_ string. If PATTERN is also omitted, splits on whitespace (after skipping any leading whitespace). Anything matching PATTERN is taken to be a delimiter separating the fields. (Note that the delimiter may be longer than one character.)

If LIMIT is specified and positive, splits into no more than that many fields (though it may split into fewer). If LIMIT is unspecified or zero, trailing null fields are stripped (which potential users of pop would do well to remember). If LIMIT is negative, it is treated as if an arbitrarily large LIMIT had been specified.

Split ist eine Perlfunktion und teilt einen String in Teilstrings auf.
Das Ergebnis ist eine Liste mit einzelnen Elementen.
Eine Liste ist entweder das mit der Schnecke dran (@liste)
oder eine Liste von Variablen ($a1,$a2,..,usw)

mfg oesi