Class::MakeMethods::Utility::ArraySplicer - Common array ops
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 ]);
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.
# 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 ]);
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 );
To install Class::MakeMethods, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Class::MakeMethods
CPAN shell
perl -MCPAN -e shell install Class::MakeMethods
For more information on module installation, please visit the detailed CPAN module installation guide.