SPVM::BlessedObject::Array - Array based blessed object
SPVM::BlessedObject::Array is array based blessed object.
This object contains SPVM array object.
# Get the value of an array element my $value = $sp_array->get(2); # Set the value of an array element $sp_array->set(2 => 5); # Convert SPVM array to Perl array reference my $elems = $sp_array->to_elems; # Convert SPVM array to Perl binary data my $binary = $sp_array->to_bin;
my $value = $sp_array->get(2);
Get the value of an array element.
$sp_array->set(2 => 5);
Set the value of an array element
my $elems = $sp_array->to_elems;
Convert SPVM array to Perl array reference.
my $binary = $sp_array->to_bin;
Convert SPVM array to binary data.
Binary data is unpacked by unpack function.
unpack
An exmaple when array is int array:
my @nums = unpack 'l*', $binary;
my $elems = $sp_array->to_strings;
Convert SPVM string array to Perl string array reference by calling to_string method of each element.
string
to_string
my $elems = $sp_array->to_bins;
Convert SPVM string array to Perl binary array reference by calling to_bin method of each element.
to_bin
SPVM::BlessedObject::Array overloads the following operators.
Array dereference get the elements of the array.
# Get elements my @elements = @$array;
This is the same as the following.
my @elements = @{$array->to_elems};
To install SPVM, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SPVM
CPAN shell
perl -MCPAN -e shell install SPVM
For more information on module installation, please visit the detailed CPAN module installation guide.