GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Text::Bidi::Array(3) User Contributed Perl Documentation Text::Bidi::Array(3)

Text::Bidi::Array - Base class for dual life arrays

version 2.15

    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

This is an abstract base class for objects that function as ``dual-life'' arrays: When viewed as an array reference, it functions as a usual array of numbers. When used as a scalar reference, it returns the same array as a packed string. The packing specification depends on the sub-class. These classes are used in Text::Bidi to conveniently pass arrays to the underlying fribidi library, but could be of independent interest.

An object of this type can be dereferenced either as a scalar or as an array. In the first case, it returns the packed (string) representation of the array. In the second, it returns the unpacked array of numbers.

The packed representation is also returned when the object is used as a string.

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

Create a new array of the given Type, and initialise it with $data. $data can be either a string, which the new object then view as an array of the given type, or an array reference (more precisely, anything that can be dereferenced as an array), which is then packed according to the rules of Type. If no $data is given, it defaults to 0.

Text::Bidi::Array::Byte, Text::Bidi::Array::Long

The rest of this documentation is for writing specific derived classes. The object is represented internally as a hashref. To implement a particular instance, the following methods should be implemented. Each of these should manipulate the field "data", which is the string that stores the actual value. Unimplemented methods will lead to croaking. See Text::Bidi::Array::Byte and Text::Bidi::Array::Long for 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'}".

Moshe Kamensky <kamensky@cpan.org>

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.

2018-09-24 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.