SPVM::B...::Array(3)
π¦ NAME π¦
okay bestie, this is the SPVM::B...::Array(3) manual page β the header abbreviates the name, but the actual package is right here and it's iconic:
SPVM::BlessedObject::Array β SPVM Array
π DESCRIPTION π
The object of the SPVM::BlessedObject::Array class holds an SPVM array. That's the whole gig β it's giving "blessed object wrapper for an SPVM array," and it ate. π«Ά
πΈ USAGE πΈ
okay so here's the quick-start flex, exactly as the page gives it:
# Gets an element of the array
my $elem = $blessed_object_array->get(2);
# Sets an element of the array
$blessed_object_array->set(2 => 5);
# Converts an SPVM array to a Perl array reference
my $elems = $blessed_object_array->to_elems;
# Converts an SPVM array to a binary
my $binary = $blessed_object_array->to_bin;
Get, set, to_elems, to_bin β four little moves and you're in your main character era. β¨
β¨ METHODS β¨
method time, bestie. These are the actual calls.
get π
my $elem = $blessed_object_array->get($index);
Returns an element of the array with the index. It's literally handing you the element at $index, no cap.
set π
$blessed_object_array->set($index, $elem);
Sets an element of the array with the index.
If $elem cannnot be assigned to the element of the array, an exception is thrown. So like, vibe check your $elem first, because the throw is coming. π
to_elems π¦
my $elems = $blessed_object_array->to_elems;
Converts an SPVM array to a Perl array reference and returns it. Perl array ref incoming, periodt.
to_bin π₯
my $binary = $blessed_object_array->to_bin;
Converts an SPVM array to a binary and returns it.
This binary is unpacked by the unpack function β the page points at https://perldoc.perl.org/functions/unpack, so keep that URL in your back pocket.
If the array is an object array, an excetion is thrown. not me warning you twice, but object arrays do not pass go here π
Examples:
# byte[]
my @elems = unpack 'c*', $binary;
# short[]
my @elems = unpack 's*', $binary;
# int[]
my @elems = unpack 'l*', $binary;
# long[]
my @elems = unpack 'q*', $binary;
# float[]
my @elems = unpack 'f*', $binary;
# double[]
my @elems = unpack 'd*', $binary;
to_strings π
my $elems = $blessed_object_array->to_strings;
Converts an SPVM string array to a Perl array reference and returns it.
Each element calls the to_string method. every single element is doing its own little to_string moment. π
to_bins π
my $elems = $blessed_object_array->to_bins;
Converts an SPVM string array to a Perl array reference and returns it.
Each element calls the to_bin method. same energy, but to_bin per element. π§
π OPERATORS π
Overloads the following operators. yes, operator overload era.
array dereference π
my @elems = @$array;
This is the same as the following operation.
my @elems = @{$array->to_elems};
so @$array is lowkey just doing @{$array->to_elems} for you. slay.
π COPYRIGHT & LICENSE π
Copyright (c) 2023 Yuki Kimoto
MIT License
periodt. respect the icon. π
mwah π β this page is from the SPVM::B...::Array(3) manual, under User Contributed Perl Documentation; the source/version is perl v5.42.2, dated 2026-02-03. byeee π«Άπ
π¦ where this page comes from
- alpine 3.24: spvm-doc 0.990125-r0 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms