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::ByteText::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$valuein the part of"$self->{'data'}"corresponding to$index.$self->FETCH($index)β fetch the value at$indexfrom 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 π«Ά
π COPYRIGHT AND LICENSE π
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
- ubuntu stonking: libtext-bidi-perl 2.18-1build5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms