-
-
23 Jan 2012 20:11:28 UTC
- Distribution: Scalar-Readonly
- Module version: 0.03
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues (2)
- Testers (2624 / 0 / 0)
- Kwalitee
Bus factor: 0- 100.00% Coverage
- License: unknown
- Activity
24 month- Tools
- Download (12.63KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- unknown
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
Scalar::Readonly - functions for controlling whether any scalar variable is read-only
SYNOPSIS
use Scalar::Readonly ':all'; my $foo = "foo"; readonly_on($foo); $foo = "bar"; #ERROR! if (readonly($foo)) { readonly_off($foo); } readonly_off($]); $] = "6.0"; print "This is Perl v$]";
DESCRIPTION
This simple module can make scalars read-only. Useful to protect configuration variables, for example.
This module can also be used to subvert Perl's many read-only variables to potential evil trickery.
readonly
Ths function takes a scalar variable and tells you whether it is read-only. It returns 0 if the scalar isn't read-only, and a positive number if it is.
readonly_on
Makes the passed scalar variable read-only. If you try and modify a read-only scalar, your code will die with the following error message:
Modification of a read-only value attempted at
readonly_off
Makes the passed scalar variable read-write. You can even do this to read-only special variables, though you almost certainly don't want to do that.
EXPORT
':all' => readonly, readonly_on, readonly_off
SEE ALSO
Scalar::Util, Attribute::Constant, Const::Fast.
AUTHOR
Philippe M. Chiasson, <gozer@cpan.org>
COPYRIGHT AND LICENSE
Copyright (C) 2004 by Philippe M. Chiasson
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.3 or, at your option, any later version of Perl 5 you may have available.
Module Install Instructions
To install Scalar::Readonly, copy and paste the appropriate command in to your terminal.
cpanm Scalar::Readonly
perl -MCPAN -e shell install Scalar::Readonly
For more information on module installation, please visit the detailed CPAN module installation guide.