Don P: wantarray

Beitrag lesen

Hallo,

Im Kontext   'name' wird dann nur ein Wert erwartet, wohingegen 'vname' auch mehrere Werte haben kann. Wie krieg ich das am Einfachsten raus?

perldoc sagt zu wantarray:

Returns true if the context of the currently executing subroutine or eval is looking for a list value. Returns false if the context is looking for a scalar. Returns the undefined value if the context is looking for no value (void context).

JavaScript kann keinen Kontext unterscheiden, also geht das so nicht.
Den Kontext muss man beim Programmieren immer kennen und entsprechend coden.

Gruß, Don P