Thread Matching von bis in einer Datei (24 answers)
Opened by Rambo at 2009-05-04 14:54

pq
 2009-07-01 18:24
#122788 #122788
User since
2003-08-04
12208 Artikel
Admin1
[Homepage]
user image
wenn ich zwei variablen erwarte und der string so aussieht: foo=bar=baz=boo, und zweimal gesplittet wird, also hinter dem foo und hinter dem bar, dann kommt als ergebnis
foo, bar, baz=boo
reicht doch aus, ich möchte zwei variablen, und die dritte lass ich wegfallen.
mit n+1 meinst du vielleicht eher die anzahl der gesplitteten elemente?

edit: um es mal klarzustellen:
($x, $y) = split m/.../, $string
wird optimiert zu:
($x, $y) = split m/.../, $string, 3

der dritte parameter ist das LIMIT für split, und das heisst, dass maximal 3 elemente entstehen, aber gesplittet (also die axt in die hand genommen und zugehauen) wird zweimal.

(zitat doku: If LIMIT is specified and positive, it represents the maximum number of fields the EXPR will be split into)
Last edited: 2009-07-01 18:41:04 +0200 (CEST)
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. -- Damian Conway in "Perl Best Practices"
lesen: Wiki:Wie frage ich & perlintro Wiki:brian's Leitfaden für jedes Perl-Problem

View full thread Matching von bis in einer Datei