06 Feb 2012 19:14:27 UTC
- Distribution: Scalar-Construct
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (1)
- Testers (566 / 42 / 0)
- KwaliteeBus factor: 1
- 100.00% Coverage
- License: perl_5
- Perl: v5.6.0
- Activity24 month
- Download (6.38KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest versionZEFRAM Andrew Main (Zefram)
Scalar::Construct - build custom kinds of scalar
use Scalar::Construct qw(constant variable aliasref aliasobj); $ref = constant($value); $ref = variable($value); $ref = aliasref(\$array); $ref = aliasobj($array);
This module supplies functions to construct Perl scalar objects. While writable (variable) scalars can easily be constructed using the ordinary facilities of the Perl language, immutable (constant) scalars require a library such as this.
Each function has two names. There is a longer descriptive name, and a shorter name to spare screen space and the programmer's fingers.
Creates a fresh immutable scalar, with value VALUE, and returns a reference to it.
If VALUE is actually a compile-time constant that can be expressed as a literal, such as
123, it would appear that a reference to a constant object with that value can be created by a Perl expression such as
\123. However, Perl has some bugs relating to compile-time constants that prevent this working as intended. On Perls built for threading (even if threading is not actually used), such a scalar will be copied at surprising times, losing both its object identity and its immutability. The function supplied by this module avoids these problems.
Creates a fresh writable scalar, initialised to value VALUE, and returns a reference to it.
OBJECT_REF must be a reference to a scalar. Returns another reference to the same scalar. (This is effectively an identity function, included for completeness.)
Returns a reference to OBJECT.
Andrew Main (Zefram) <email@example.com>
Copyright (C) 2012 Andrew Main (Zefram) <firstname.lastname@example.org>
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Module Install Instructions
To install Scalar::Construct, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Scalar::Construct
For more information on module installation, please visit the detailed CPAN module installation guide.