Software Index
Linux Software Programming  

Attribute::Handlers

download download home home   report broken
important software information
company name:
Steffen Muller
license: Freeware
minimum requirements:
functional limitations:
Attribute::Handlers description
The Attribute::Handlers Perl module, when inherited by a package, allows that package's class to define attribute handler subroutines for specific attributes. Variables and subroutines subsequently defined in that package, or in packages derived from that package may be given attributes with the same names as the attribute handler subroutines, which will then be called in one of the compilation phases (i.e. in a BEGIN, CHECK, INIT, or END block). (UNITCHECK blocks don't correspond to a global compilation phase, so they can't be specified here.)

To create a handler, define it as a subroutine with the same name as the desired attribute, and declare the subroutine itself with the attribute :ATTR. For example:

package LoudDecl;
use Attribute::Handlers;

sub Loud :ATTR {
my ($package, $symbol, $referent, $attr, $data, $phase, $filename, $linenum) = @_;
print STDERR
ref($referent), " ",
*{$symbol}{NAME}, " ",
"($referent) ", "was just declared ",
"and ascribed the ${attr} attribute ",
"with data ($data)
",
"in phase $phase
",
"in file $filename at line $linenum
";
}

This creates a handler for the attribute :Loud in the class LoudDecl. Thereafter, any subroutine declared with a :Loud attribute in the class LoudDecl:

package LoudDecl;

sub foo: Loud {...}

causes the above handler to be invoked, and passed:

[0]

the name of the package into which it was declared;
[1]

a reference to the symbol table entry (typeglob) containing the subroutine;
[2]

a reference to the subroutine;
[3]

the name of the attribute;
[4]

any data associated with that attribute;
[5]

the name of the phase in which the handler is being invoked;
[6]

the filename in which the handler is being invoked;
[7]

the line number in this file.

SYNOPSIS

package MyClass;
require 5.006;
use Attribute::Handlers;
no warnings 'redefine';


sub Good : ATTR(SCALAR) {
my ($package, $symbol, $referent, $attr, $data) = @_;

# Invoked for any scalar variable with a :Good attribute,
# provided the variable was declared in MyClass (or
# a derived class) or typed to MyClass.

# Do whatever to $referent here (executed in CHECK phase).
...
}

sub Bad : ATTR(SCALAR) {
# Invoked for any scalar variable with a :Bad attribute,
# provided the variable was declared in MyClass (or
# a derived class) or typed to MyClass.
...
}

sub Good : ATTR(ARRAY) {
# Invoked for any array variable with a :Good attribute,
# provided the variable was declared in MyClass (or
# a derived class) or typed to MyClass.
...
}

sub Good : ATTR(HASH) {
# Invoked for any hash variable with a :Good attribute,
# provided the variable was declared in MyClass (or
# a derived class) or typed to MyClass.
...
}

sub Ugly : ATTR(CODE) {
# Invoked for any subroutine declared in MyClass (or a
# derived class) with an :Ugly attribute.
...
}

sub Omni : ATTR {
# Invoked for any scalar, array, hash, or subroutine
# with an :Omni attribute, provided the variable or
# subroutine was declared in MyClass (or a derived class)
# or the variable was typed to MyClass.
# Use ref($_[2]) to determine what kind of referent it was.
...
}


use Attribute::Handlers autotie => { Cycle => Tie::Cycle };

my $next : Cycle(['A'..'Z']);. .
Similar software
HTML::TagFilter (Popularity: ) : HTML::TagFilter is a fine-grained html-filter, xss-blocker and mailto-obfuscator.

SYNOPSIS

use HTML::TagFilter;
my $tf = new HTML::TagFilter;
my $clean_html = $tf->filter($dirty_html);

# or

my $tf = HTML::TagFilter->new(
allow=>{...},
deny=>{...},
log_rejects => 1,
strip_comments => 1,
echo => 1,
verbose => 1,
skip_xss_protection ...

web2ldap (Popularity: ) : web2ldap is an LDAP client written in Python, full-featured and designed to run as a stand-alone Web gateway or under the control of a web server with FastCGI support (e.g., Apache with mod_fastcgi).

Here are some key features of "web2ldap":

· Full ...

Bottle (Popularity: ) : Bottle is a fast, simple and useful one-file WSGI framework. It is not a full-stack framework with a ton of features, but a useful mirco-framework for small web-applications that stays out of your way.

Bottle only depends on the Python Standard ...

Bunch for Linux (Popularity: ) : Bunch is a dictionary which supports attribute-style access, a la javascript.

>>> b = Bunch()
>>> b.hello = 'world'
>>> b.hello
'world'
>>> b['hello'] += "!"
>>> b.hello
'world!'
>>> b.foo = Bunch(lol=True)
>>> b.foo.lol
True
>>> b.foo is b['foo']
True

Dictionary Methods

A Bunch is a subclass of dict; it supports all the ...

CPAN::DistroBuilder (Popularity: ) : PAN::DistroBuilder is a Perl module to create a distro from a bundle or a number of modules from CPAN.

SYNOPSIS

% perl -MCPAN::DistroBuilder -webuild ApacheSDK 0.1 Bundle::Apache

% perl -MCPAN::DistroBuilder -webuild CoolSDK 0.1 MD5 CGI

This package does a very simple thing. It fetches ...

Simple Groupware for Linux (Popularity: ) : Simple Groupware 0.2 beta 1 has been released and is available for download at. Simple Groupware has lots of new features that are building the basis for new features, better performance and many more releases.

New features/changes (very short): Added folder ...

NetSNMP::TrapReceiver (Popularity: ) : NetSNMP::TrapReceiver is a Perl module used to register Perl subroutines into the Net-SNMP snmptrapd process. Net-SNMP MUST have been configured using --enable-embedded-perl. Registration of functions is then done through the snmptrapd.conf configuration file. This module can NOT be used in ...
gtkmm for Linux (Popularity: ) : gtkmm is the official C++ interface for the popular GUI library GTK+.

Highlights of gtkmm include typesafe callbacks, widgets extensible via inheritance and a comprehensive set of widgets.

You can create user interfaces either in code or with the Glade designer, using ...

HPUX::LVM (Popularity: ) : HPUX::LVM is a Perl module that takes the output from the LVM Commands vgdisplay and lvdisplay and pvdisplay and puts them in a hash of hashes in the following manner as an example:

'/dev/vg08' => HASH(0x404214c8)
'Act_PV' => 4
'Alloc_PE' ...

Advanced Dork: (Popularity: ) : Advanced Dork: is an extension which gives quick access to Google's Advanced Operators directly from the context menu.

Here are some key features of "Advanced Dork ":

. Highlight any text, right click, and choose from over 15 Advanced Google Operators. This ...

Android X GTK (Popularity: ) : Android X GTK is a painstakingly modded theme, based on a Murrine theme.

How to install?

· Right click on your desktop and select Change Desktop Background
· Click on the first tab: Theme
· Drag and drop the theme's archive in the Appearance ...

User reviews

Write a review:
1 2 3 4 5 6 7 8 9 10
1=poor 10=excellent
Write review*
Your name*
Email*
  (Comments are moderated, and will not appear on this site until the editor has approved them)
 
Similar scripts
Dictionary with attribute-style access (Popularity: ) : This script defines a dictionary with attribute-style access. It maps attribute access to the real dictionary.It can be easier to read and type data access using the simpler attribute syntax (one dot), that using a lot of square-brackets and quotes. ...
Public and protected attribute access (Popularity: ) : This script presents a way to introduce proper attribute access protection levels using a generic proxy object. By default all attributes are "protected" in the C sense and can be declared as public using either a function decorator or a ...
Simplified attribute accessors using ove (Popularity: ) : This script presents an ideom for simplified accessors, that combines typical getter and setter functionality of an attribute into a single overloaded method, that instead of getATTRIBUTE and setATTRIBUTE can now just be called ATTRIBUTE. When called without arguments it ...
image_tag with popup for alt attribute (Popularity: ) : Firefox doesn't display a popup for the alt attribute for images. While this is according to spec, it's slightly annoying to put the same text in both the alt and the title.Put the following in your ApplicationHelper to copy the ...
Actual Attribute Price (Popularity: ) : Actual Attribute Price is designed for those of us who would rather use a product attributes actual price rather than use a calculator to figure out the option priceExample:--------Tire APrice: $84.99Options: Size 1Size 2 ($89.99)Size 3 ($95.99)Size 4 ($109.99)Versus-------Tire BPrice: ...
Simplified attribute accessors using overloading (Popularity: ) : This script presents an ideom for simplified accessors, that combines typical getter and setter functionality of an attribute into a single overloaded method, that instead of getATTRIBUTE and setATTRIBUTE can now just be called ATTRIBUTE. When called without arguments it ...
Total Commander MATLAB packer plugin (Popularity: ) : This plugin gives Total Commander access to Matlab(R) files in MAT formatIt has been tested with MAT files version 4 and 5 (Matlab R12, R13, R14, not tested with R14SP1).Key Functionality=================- Browsing of Matlab files in MAT formats (version 4 ...
Plots a surface coloring by layers (using contour curves) (Popularity: ) : Different elevations cannot be identified with standard matlab functions such as surf, even changing FaceColor attribute to activate interpolation. In contrast, with this function alows one can define contour levels and different colors are applied to each level.Instead of using ...
Ubercart Ajax Attribute Calculations (Popularity: ) : uc_aac is an add-on module for the Ubercart e-commerce suite. This module updates product fields via Ajax when attributes that effect those fields are modified. By default it also updates individual attribute price adjustments so that they remain relative to ...
OpenID Attribute Exchange Implementation (Popularity: ) : OpenID Attribute Exchange is an extension for OpenID service which allows the transfer of various user related details/information/attributes between the relying party and the identity provider. There are two primary operations that can be done using the Attribute Exchange:a) Fetch/retrieve ...
Rate me
supported os's
stats
downloads 4
version 0.85
size in Kb 20
popularity   
765/1272475
user rating 0/10
our rating 0 Stars
share info
Recommend Attribute::Handlers
Report spyware
New Software
Popular Software
Latest Reviews