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


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

This is a general-purpose array accessor function. Depending on the arguments passed to it, it will get, set, slice, splice, or otherwise modify your array.

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_splice, [ 2, 3 ] );
  
  # 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 );


SEE ALSO

See the Class::MakeMethods manpage for general information about this distribution.

See the Class::MakeMethods::Standard::Hash manpage and numerous other classes for examples of usage.

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