push#

Add elements to the end of a $DB_RECNO array.

Synopsis#

$db->push('one', 'two');
push @lines, 'three';

What you get back#

0, or the error of the element that could not be stored - the elements after it are not stored either. PUSH is the same method under the name the tied array calls.

Edge cases#

  • With no elements to add it returns 0 for an array that has elements, and -30987 (Berkeley DB’s DB_NOTFOUND) for an empty one.

  • The new elements follow the last element that holds a value.

Differences from upstream#

Fully compatible with upstream. Covered by t/81-xs-native/DB_File/010-phenotype.t.

See also#

  • pop - takes the last element off again

  • unshift - adds at the start