NAME

Class::MakeMethods::Utility::ArraySplicer - Common array ops

SYNOPSIS

use Class::MakeMethods::Utility::ArraySplicer;

# Get one or more values
$value = array_splicer( $array_ref, $index );
@values = array_splicer( $array_ref, $index_array_ref );

# Set one or more values
array_splicer( $array_ref, $index => $new_value, ... );

# Splice selected values in or out
array_splicer( $array_ref, [ $start_index, $end_index], [ @values ]);

DESCRIPTION

This module provides a utility function and several associated constants which support a general purpose array-splicer interface, used by several of the Standard and Composite method generators.

array_splicer

# Get one or more values
$value = array_splicer( $array_ref, $index );
@values = array_splicer( $array_ref, $index_array_ref );

# Set one or more values
array_splicer( $array_ref, $index => $new_value, ... );

# Splice selected values in or out
array_splicer( $array_ref, [ $start_index, $end_index], [ @values ]);

Constants

There are also constants symbols to facilitate some common combinations of splicing arguments:

# Reset the array contents to empty
array_splicer( $array_ref, array_clear );

# Set the array contents to provided values
array_splicer( $array_ref, array_set, [ 'Foozle', 'Bazzle' ] );

# Unshift an item onto the front of the list
array_splicer( $array_ref, array_unshift, 'Bubbles' );

# Shift it back off again
print array_splicer( $array_ref, array_shift );

# Push an item onto the end of the list
array_splicer( $array_ref, array_push, 'Bubbles' );

# Pop it back off again
print array_splicer( $array_ref, array_pop );