Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Strict to references of a particular Variable of particular type.

by Zaxo (Archbishop)
on Dec 02, 2005 at 13:00 UTC ( [id://513583]=note: print w/replies, xml ) Need Help??


in reply to Strict to references of a particular Variable of particular type.

use Tie::Constrained; tie my $array_ref, 'Tie::Constrained', sub { ref $_[0] eq 'ARRAY' };
After that, an attempt to assign anything but an unblessed array ref will fail. Continuing,
tie my $hash_ref, 'Tie::Constrained', sub { ref $_[0] eq 'HASH' }; tie my $scalar_ref, 'Tie::Constrained', sub { ref $_[0] eq 'SCALAR' }; tie my $scalar_value, 'Tie::Constrained', sub { not ref $_[0] }; tie my $query, 'Tie::Constrained', sub { ref $_[0] and $_[0]->isa('CGI') }, CGI->new;
There are all kinds of possibilities.

After Compline,
Zaxo

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://513583]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (7)
As of 2024-03-29 08:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found