Re: Use of implicit split to @_ is deprecated



Michael Holzt:
Doku lesen hilft:

| In scalar context, returns the number of fields found and splits
| into the @_ array. Use of split in scalar context is deprecated,
| however, because it clobbers your subroutine arguments.

Erstmal danke an alle, die mir geantwortet haben. Wieder einmal
ist es erstaunlich, wieviele Möglichkeiten Perl zu Lösung eines
Problems anbietet. Mir gefällt die tr-Variante von Michael am
besten.

Ich muss gestehen, ich habe die Doku zu split nicht gelesen
(mea maximal culpa). Offensichtlich verwendet split das Array
@_ zum Zwischenspeichern der Elemente, um die Elementanzahl
ermitteln zu können. Das kann natürlich in Funktionen (ich
verwende es allerdings nicht innerhalb einer solchen) Probleme
machen, wenn damit die der Funktion übergebene Argumentliste
überschrieben wird. Insoferne ist die Meldung ja verständlich.
Unverständlich ist mir hingegen, wieso zum Zwischenspeichern
nicht eine andere (interne) Variable verwendet wird (wie z.B.
beim autosplit mit dem -a Switch, wo @F verwendet wird).

Vielleicht wird das in Perl 6 ja konsistenter gelöst sein.

LG, Ferry

--
Ing Ferry Bolhar
Magistrat der Stadt Wien - MA 14
A-1010 Wien
E-Mail: ferdinand.bolhar-nordenkampf@xxxxxxxxxx

.



Relevant Pages

  • Re: Learning Perl
    ... it should be an array, ... Then they'd be completely inaccessible to beginners. ... that should be my $var. ... so why is it redundant to point out that Perl is different from C here? ...
    (comp.lang.perl.misc)
  • Re: Which is faster - hash or array lookup
    ... I am suite sure that perl is not The Right Tool ... Each player has 5 pieces, and additionally there is a common ... whereas traversing an array looking for $n is slow). ...
    (comp.lang.perl.misc)
  • Re: perl vs Unix grep
    ... variable indexCount on array and reintialized evry time. ... Perl is langauge to make things work at any cost. ... > grep but the shell scripts that use ... As far as I can tell from reading and research ...
    (comp.lang.perl)
  • FAQ 4.42 How can I tell whether a certain element is contained in a list or array?
    ... comes with the standard Perl distribution. ... How can I tell whether a certain element is contained in a list or array? ... used a hash, not a list or array, to store your data. ... The perlfaq-workers, a group of volunteers, maintain the perlfaq. ...
    (comp.lang.perl.misc)
  • FAQ 4.42 How can I tell whether a certain element is contained in a list or array?
    ... comes with the standard Perl distribution. ... How can I tell whether a certain element is contained in a list or array? ... used a hash, not a list or array, to store your data. ... The perlfaq-workers, a group of volunteers, maintain the perlfaq. ...
    (comp.lang.perl.misc)