Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

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

by Zaxo (Archbishop)
on Dec 02, 2005 at 13:00 UTC ( #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
Node Status?
node history
Node Type: note [id://513583]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2019-07-22 10:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If you were the first to set foot on the Moon, what would be your epigram?






    Results (14 votes). Check out past polls.

    Notices?