Text::...::Array(3pm)

✨ Text::Bidi::Array ✨

okay bestie, welcome to Text::Bidi::Array β€” part of the Perl 5 docs, and honestly it's giving quiet overachiever. πŸ’…

πŸ’– NAME πŸ’–

Text::Bidi::Array β€” the base class for dual life arrays. yes babes, arrays with TWO whole personalities. πŸ¦‹

🌸 VERSION 🌸

version 2.18 β€” she's a specific girlie and we respect that.

✨ SYNOPSIS ✨

use Text::Bidi::Array::Byte;
my $a = new Text::Bidi::Array::Byte "abc";
say $a->[1]; # says 98
say $$a; # says abc
say "$a"; # also says abc

see how she said abc twice?? versatile. multi-talented. main character energy fr fr. πŸ‘‘

πŸŽ€ DESCRIPTION πŸŽ€

so this is an abstract base class β€” meaning she's the blueprint, not the final form, no cap. She's for objects that act like "dual-life" arrays, which is a fancy way of saying:

  • when you look at it like an array reference, it's just a normal array of numbers
  • when you look at it like a scalar reference, it hands you back that exact same array as a packed string

the packing spec? depends on the sub-class, so that's on them not her. πŸ’…

these classes get used over in Text::Bidi because it's convenient for passing arrays down to the underlying fribidi library β€” but bestie, they could totally be of independent interest. lowkey iconic. 🌈

πŸ”₯ OVERLOADED OPERATORS πŸ”₯

an object of this type can be dereferenced either as a scalar or as an array, and the two vibes are completely different:

  • as a scalar β†’ you get the packed (string) representation of the array
  • as an array β†’ you get the unpacked array of numbers

and plot twist: that same packed representation also shows up when the object is used as a string. it's giving consistent. ✨

🧚 CONSTRUCTION 🧚

$a = new Text::Bidi::Array::<Type> $data

make a brand new array of the given Type, and initialise it with $data. πŸ’–

and what even is $data? bestie it can be one of two things:

  • a string β€” and then the new object views it as an array of the given type
  • an array reference β€” or more precisely, anything that can be dereferenced as an array β€” which then gets packed according to the rules of Type

and if you don't pass $data at all? no worries, it just defaults to 0. she's easygoing like that. πŸ™ˆ

πŸ¦‹ SEE ALSO πŸ¦‹

  • Text::Bidi::Array::Byte
  • Text::Bidi::Array::Long

πŸ‘‘ FOR IMPLEMENTORS πŸ‘‘

⚠️ heads up: the rest of this doc is for people writing their own specific derived classes. if that's not you, you can scroll away, no hard feelings. πŸ’œ

internally the object is represented as a hashref. to implement a particular instance, you gotta implement the following methods. each one of these should be manipulating the field "data" β€” that's the string storing the actual value. and if you leave methods unimplemented?? croaking. πŸ’€ not cute, so don't.

peep Text::Bidi::Array::Byte and Text::Bidi::Array::Long if you want examples. πŸ“

  • $self->pack(@data) β€” convert (pack) an array of numbers into a string according to the format of the current class. this will probably be a class method. returns the string. πŸ’…

the following methods should behave as described in Tie::Array:

  • $self->STORE($index, $value) β€” store the $value in the part of "$self->{'data'}" corresponding to $index.
  • $self->FETCH($index) β€” fetch the value at $index from the correct part of "$self->{'data'}".
  • $self->STORESIZE($count) β€” modify "$self->{'data'}" to represent an array of size $count.
  • $self->FETCHSIZE() β€” return the size of the array represented by "$self->{'data'}".

πŸ’œ AUTHOR πŸ’œ

Moshe Kamensky <kamensky@cpan.org> β€” thank you king 🫢

This software is copyright (c) 2015 by Moshe Kamensky.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


and that's the whole page bestie!! πŸ’– this one's from perl v5.42.3, dated 2026-08-19, and the manpage is Text::Bidi::Array(3pm). slay, go write urself a subclass, ily πŸŒΈβœ¨πŸŽ€

πŸ“¦ where this page comes from