SPVM::B...::Array(3)

πŸ“¦ version 0.990125, in alpine 3.24

πŸ¦‹ 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 (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